diff options
author | Vitalii Dmitriev <vitalii.dmitriev@unikie.com> | 2023-12-18 11:25:16 +0200 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-12-20 07:38:49 +0000 |
commit | 449b23b698d7d4b13909667a49a0698eb495eeaa (patch) | |
tree | 58a391c600b5838e1c660864ad102f9fb468d312 /tests | |
parent | e5fb6e585f593162ee2b10ad64cdd7ea2a577a06 (diff) | |
download | git-repo-449b23b698d7d4b13909667a49a0698eb495eeaa.tar.gz |
manifest_xml: fix url normalization for inits and remotes
Before the change, repo normalizes the urls
with a following format only:
git@github.com:foo/bar
It doesn't cover the following case:
<remote name="org" fetch="git@github.com:org/" />
<project name="somerepo" remote="org" />
Results to:
error: Cannot fetch somerepo
from ssh://git@github.com/org/git@github.com:org/somerepo
Current change fixes it by normalizing this format:
git@github.com:foo
Test: ./run_tests tests/test_manifest_xml.py
Change-Id: I1ad0f5df0d52c0b7229ba4c9a4db4eecb5c1a003
Signed-off-by: Vitalii Dmitriev <vitalii.dmitriev@unikie.com>
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/398337
Commit-Queue: Vitalii Dmitriev <dmit.vitalii@gmail.com>
Tested-by: Vitalii Dmitriev <dmit.vitalii@gmail.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_manifest_xml.py | 36 |
1 files changed, 36 insertions, 0 deletions
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) | ||