mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
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>
This commit is contained in:
committed by
Mike Frysinger
parent
696e0c48a9
commit
be71c2f80f
@ -996,6 +996,44 @@ class RemoveProjectElementTests(ManifestParseTestCase):
|
||||
)
|
||||
self.assertEqual(manifest.projects, [])
|
||||
|
||||
def test_remove_using_path_attrib(self):
|
||||
manifest = self.getXmlManifest(
|
||||
"""
|
||||
<manifest>
|
||||
<remote name="default-remote" fetch="http://localhost" />
|
||||
<default remote="default-remote" revision="refs/heads/main" />
|
||||
<project name="project1" path="tests/path1" />
|
||||
<project name="project1" path="tests/path2" />
|
||||
<project name="project2" />
|
||||
<project name="project3" />
|
||||
<project name="project4" path="tests/path3" />
|
||||
<project name="project4" path="tests/path4" />
|
||||
<project name="project5" />
|
||||
<project name="project6" path="tests/path6" />
|
||||
|
||||
<remove-project name="project1" path="tests/path2" />
|
||||
<remove-project name="project3" />
|
||||
<remove-project name="project4" />
|
||||
<remove-project path="project5" />
|
||||
<remove-project path="tests/path6" />
|
||||
</manifest>
|
||||
"""
|
||||
)
|
||||
found_proj1_path1 = False
|
||||
found_proj2 = False
|
||||
for proj in manifest.projects:
|
||||
if proj.name == "project1":
|
||||
found_proj1_path1 = True
|
||||
self.assertEqual(proj.relpath, "tests/path1")
|
||||
if proj.name == "project2":
|
||||
found_proj2 = True
|
||||
self.assertNotEqual(proj.name, "project3")
|
||||
self.assertNotEqual(proj.name, "project4")
|
||||
self.assertNotEqual(proj.name, "project5")
|
||||
self.assertNotEqual(proj.name, "project6")
|
||||
self.assertTrue(found_proj1_path1)
|
||||
self.assertTrue(found_proj2)
|
||||
|
||||
|
||||
class ExtendProjectElementTests(ManifestParseTestCase):
|
||||
"""Tests for <extend-project>."""
|
||||
|
Reference in New Issue
Block a user