diff options
-rw-r--r-- | manifest_xml.py | 4 | ||||
-rw-r--r-- | tests/test_manifest_xml.py | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 7e533a02..4f752122 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -133,8 +133,8 @@ def normalize_url(url: str) -> str: | |||
133 | url = url.rstrip("/") | 133 | url = url.rstrip("/") |
134 | parsed_url = urllib.parse.urlparse(url) | 134 | parsed_url = urllib.parse.urlparse(url) |
135 | 135 | ||
136 | # This matches patterns like "git@github.com:foo/bar". | 136 | # This matches patterns like "git@github.com:foo". |
137 | scp_like_url_re = r"^[^/:]+@[^/:]+:[^/]+/" | 137 | scp_like_url_re = r"^[^/:]+@[^/:]+:[^/]+" |
138 | 138 | ||
139 | # If our URL is missing a schema and matches git's | 139 | # If our URL is missing a schema and matches git's |
140 | # SCP-like syntax we should convert it to a proper | 140 | # SCP-like syntax we should convert it to a proper |
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 6423bb96..3f03272a 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -1139,6 +1139,9 @@ class NormalizeUrlTests(ManifestParseTestCase): | |||
1139 | "http://foo.com/bar/baz", manifest_xml.normalize_url(url) | 1139 | "http://foo.com/bar/baz", manifest_xml.normalize_url(url) |
1140 | ) | 1140 | ) |
1141 | 1141 | ||
1142 | url = "http://foo.com/bar/" | ||
1143 | self.assertEqual("http://foo.com/bar", manifest_xml.normalize_url(url)) | ||
1144 | |||
1142 | def test_has_leading_slash(self): | 1145 | def test_has_leading_slash(self): |
1143 | """SCP-like syntax except a / comes before the : which git disallows.""" | 1146 | """SCP-like syntax except a / comes before the : which git disallows.""" |
1144 | url = "/git@foo.com:bar/baf" | 1147 | url = "/git@foo.com:bar/baf" |
@@ -1157,9 +1160,15 @@ class NormalizeUrlTests(ManifestParseTestCase): | |||
1157 | url = "foo.com/baf/bat" | 1160 | url = "foo.com/baf/bat" |
1158 | self.assertEqual(url, manifest_xml.normalize_url(url)) | 1161 | self.assertEqual(url, manifest_xml.normalize_url(url)) |
1159 | 1162 | ||
1163 | url = "foo.com/baf" | ||
1164 | self.assertEqual(url, manifest_xml.normalize_url(url)) | ||
1165 | |||
1160 | url = "git@foo.com/baf/bat" | 1166 | url = "git@foo.com/baf/bat" |
1161 | self.assertEqual(url, manifest_xml.normalize_url(url)) | 1167 | self.assertEqual(url, manifest_xml.normalize_url(url)) |
1162 | 1168 | ||
1169 | url = "git@foo.com/baf" | ||
1170 | self.assertEqual(url, manifest_xml.normalize_url(url)) | ||
1171 | |||
1163 | url = "/file/path/here" | 1172 | url = "/file/path/here" |
1164 | self.assertEqual(url, manifest_xml.normalize_url(url)) | 1173 | self.assertEqual(url, manifest_xml.normalize_url(url)) |
1165 | 1174 | ||
@@ -1168,3 +1177,30 @@ class NormalizeUrlTests(ManifestParseTestCase): | |||
1168 | self.assertEqual( | 1177 | self.assertEqual( |
1169 | "ssh://git@foo.com/bar/baf", manifest_xml.normalize_url(url) | 1178 | "ssh://git@foo.com/bar/baf", manifest_xml.normalize_url(url) |
1170 | ) | 1179 | ) |
1180 | |||
1181 | url = "git@foo.com:bar/" | ||
1182 | self.assertEqual( | ||
1183 | "ssh://git@foo.com/bar", manifest_xml.normalize_url(url) | ||
1184 | ) | ||
1185 | |||
1186 | def test_remote_url_resolution(self): | ||
1187 | remote = manifest_xml._XmlRemote( | ||
1188 | name="foo", | ||
1189 | fetch="git@github.com:org2/", | ||
1190 | manifestUrl="git@github.com:org2/custom_manifest.git", | ||
1191 | ) | ||
1192 | self.assertEqual("ssh://git@github.com/org2", remote.resolvedFetchUrl) | ||
1193 | |||
1194 | remote = manifest_xml._XmlRemote( | ||
1195 | name="foo", | ||
1196 | fetch="ssh://git@github.com/org2/", | ||
1197 | manifestUrl="git@github.com:org2/custom_manifest.git", | ||
1198 | ) | ||
1199 | self.assertEqual("ssh://git@github.com/org2", remote.resolvedFetchUrl) | ||
1200 | |||
1201 | remote = manifest_xml._XmlRemote( | ||
1202 | name="foo", | ||
1203 | fetch="git@github.com:org2/", | ||
1204 | manifestUrl="ssh://git@github.com/org2/custom_manifest.git", | ||
1205 | ) | ||
1206 | self.assertEqual("ssh://git@github.com/org2", remote.resolvedFetchUrl) | ||