Skip to content

Commit c99b25e

Browse files
committed
feat: update urls in the migrated pom.xml
1 parent ae153dd commit c99b25e

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

monorepo-migration/migrate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): update copyright heade
246246
# 7.9 Modernize root pom.xml
247247
echo "Modernizing root pom.xml..."
248248
PARENT_VERSION=$(grep -m 1 "<version>.*{x-version-update:google-cloud-java:current}" google-cloud-jar-parent/pom.xml | sed -E 's/.*<version>(.*)<\/version>.*/\1/')
249-
python3 "$MODERNIZE_POM_SCRIPT" "$SOURCE_REPO_NAME/pom.xml" "$PARENT_VERSION"
249+
python3 "$MODERNIZE_POM_SCRIPT" "$SOURCE_REPO_NAME/pom.xml" "$PARENT_VERSION" "$SOURCE_REPO_NAME"
250250

251251
echo "Committing root pom.xml modernization..."
252252
git add "$SOURCE_REPO_NAME/pom.xml"

monorepo-migration/modernize_pom.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sys
1616
import re
1717

18-
def modernize_pom(file_path, parent_version):
18+
def modernize_pom(file_path, parent_version, source_repo_name=None):
1919
with open(file_path, 'r') as f:
2020
lines = f.readlines()
2121

@@ -29,6 +29,33 @@ def modernize_pom(file_path, parent_version):
2929
has_x_version_update = False
3030

3131
for line in lines:
32+
# URL Modernization
33+
if any(tag in line for tag in ['<url>', '<connection>', '<developerConnection>']):
34+
if 'github.com' in line and 'googleapis/' in line:
35+
if source_repo_name:
36+
repo_pattern = re.escape(source_repo_name)
37+
else:
38+
repo_pattern = r'[a-zA-Z0-9-]+'
39+
40+
# Replace HTTPS URLs
41+
line = re.sub(
42+
r'https://github\.com/googleapis/' + repo_pattern,
43+
'https://github.com/googleapis/google-cloud-java',
44+
line
45+
)
46+
# Replace Git SSH URLs
47+
line = re.sub(
48+
r'git@github\.com:googleapis/' + repo_pattern + r'(\.git)?',
49+
'git@github.com:googleapis/google-cloud-java.git',
50+
line
51+
)
52+
# Handle scm:git: prefix if it has https
53+
line = re.sub(
54+
r'scm:git:https://github\.com/googleapis/' + repo_pattern,
55+
'scm:git:https://github.com/googleapis/google-cloud-java.git',
56+
line
57+
)
58+
3259
# Parent section modernization
3360
if '<parent>' in line and not in_parent:
3461
in_parent = True
@@ -110,7 +137,8 @@ def modernize_pom(file_path, parent_version):
110137

111138
if __name__ == "__main__":
112139
if len(sys.argv) > 2:
113-
modernize_pom(sys.argv[1], sys.argv[2])
140+
source_repo = sys.argv[3] if len(sys.argv) > 3 else None
141+
modernize_pom(sys.argv[1], sys.argv[2], source_repo)
114142
else:
115-
print("Usage: python3 modernize_pom.py <file_path> <parent_version>")
143+
print("Usage: python3 modernize_pom.py <file_path> <parent_version> [source_repo_name]")
116144
sys.exit(1)

0 commit comments

Comments
 (0)