From 3652b497bbbd6227b2cb84bb61a0fe8d21ba20d6 Mon Sep 17 00:00:00 2001 From: Michael Kelly Date: Tue, 19 Sep 2023 09:51:03 -0700 Subject: Correctly handle schema-less URIs for remote fetch URL Currently we don't deal with schema-less URIs like `git@github.com:foo` at all resulting in a scenario where we append them to the manifest repo URL. In order to deal with this, we munge both the manifest URL and the fetch URL into a format we like and proceed with that. Bug: https://g-issues.gerritcodereview.com/issues/40010331 Change-Id: I7b79fc4ed276630fdbeb235b94e327b172f0879b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386954 Reviewed-by: Mike Frysinger Tested-by: Michael Kelly Commit-Queue: Mike Frysinger --- tests/test_manifest_xml.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 3fcf09fa..11c0c15e 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -1128,3 +1128,32 @@ class ExtendProjectElementTests(ManifestParseTestCase): ) self.assertEqual(len(manifest.projects), 1) self.assertEqual(manifest.projects[0].upstream, "bar") + + +class NormalizeUrlTests(ManifestParseTestCase): + """Tests for normalize_url() in manifest_xml.py""" + + def test_has_trailing_slash(self): + url = "http://foo.com/bar/baz/" + self.assertEqual( + "http://foo.com/bar/baz", manifest_xml.normalize_url(url) + ) + + def test_has_no_scheme(self): + """Deal with cases where we have no scheme, but we also + aren't dealing with the git SCP-like syntax + """ + url = "foo.com/baf/bat" + self.assertEqual(url, manifest_xml.normalize_url(url)) + + url = "git@foo.com/baf/bat" + self.assertEqual(url, manifest_xml.normalize_url(url)) + + url = "/file/path/here" + self.assertEqual(url, manifest_xml.normalize_url(url)) + + def test_has_no_scheme_matches_scp_like_syntax(self): + url = "git@foo.com:bar/baf" + self.assertEqual( + "ssh://git@foo.com/bar/baf", manifest_xml.normalize_url(url) + ) -- cgit v1.2.3-54-g00ecf