summaryrefslogtreecommitdiffstats
path: root/tests/test_manifest_xml.py
diff options
context:
space:
mode:
authorFredrik de Groot <fredrik.de.groot@aptiv.com>2023-05-31 16:56:34 +0200
committerMike Frysinger <vapier@google.com>2023-06-21 14:50:16 +0000
commitbe71c2f80fa115e8256211fd0e3116d93cfae93e (patch)
tree39769fb002ec24d520abde60cf6b0614c4c02558 /tests/test_manifest_xml.py
parent696e0c48a9de4d20f3de65bc014ca2991d16f041 (diff)
downloadgit-repo-be71c2f80fa115e8256211fd0e3116d93cfae93e.tar.gz
manifest: enable remove-project using path
A something.xml that gets included by two different files, that both remove and add same shared project to two different locations, would not work prior to this change. Reason is that remove killed all name keys, even though reuse of same repo in different locations is allowed. Solve by adding optional attrib path to <remove-project name="foo" path="only_this_path" /> and tweak remove-project. Behaves as before without path, and deletes more selectively when remove path is supplied. As secondary feature, a project can now also be removed by only using path, assuming a matching project name can be found. Change-Id: I502d9f949f5d858ddc1503846b170473f76dc8e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375694 Tested-by: Fredrik de Groot <fredrik.de.groot@aptiv.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r--tests/test_manifest_xml.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index ef511055..1015e114 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -996,6 +996,44 @@ class RemoveProjectElementTests(ManifestParseTestCase):
996 ) 996 )
997 self.assertEqual(manifest.projects, []) 997 self.assertEqual(manifest.projects, [])
998 998
999 def test_remove_using_path_attrib(self):
1000 manifest = self.getXmlManifest(
1001 """
1002<manifest>
1003 <remote name="default-remote" fetch="http://localhost" />
1004 <default remote="default-remote" revision="refs/heads/main" />
1005 <project name="project1" path="tests/path1" />
1006 <project name="project1" path="tests/path2" />
1007 <project name="project2" />
1008 <project name="project3" />
1009 <project name="project4" path="tests/path3" />
1010 <project name="project4" path="tests/path4" />
1011 <project name="project5" />
1012 <project name="project6" path="tests/path6" />
1013
1014 <remove-project name="project1" path="tests/path2" />
1015 <remove-project name="project3" />
1016 <remove-project name="project4" />
1017 <remove-project path="project5" />
1018 <remove-project path="tests/path6" />
1019</manifest>
1020"""
1021 )
1022 found_proj1_path1 = False
1023 found_proj2 = False
1024 for proj in manifest.projects:
1025 if proj.name == "project1":
1026 found_proj1_path1 = True
1027 self.assertEqual(proj.relpath, "tests/path1")
1028 if proj.name == "project2":
1029 found_proj2 = True
1030 self.assertNotEqual(proj.name, "project3")
1031 self.assertNotEqual(proj.name, "project4")
1032 self.assertNotEqual(proj.name, "project5")
1033 self.assertNotEqual(proj.name, "project6")
1034 self.assertTrue(found_proj1_path1)
1035 self.assertTrue(found_proj2)
1036
999 1037
1000class ExtendProjectElementTests(ManifestParseTestCase): 1038class ExtendProjectElementTests(ManifestParseTestCase):
1001 """Tests for <extend-project>.""" 1039 """Tests for <extend-project>."""