mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-01-11 17:10:33 +00:00
manifest: Make include groups propagate to extend-project elements
Any groups specified to an include element should propagate to any extend-project elements and then on to the projects. Change-Id: I62b95689cc13660858564ae569cbfd095961ecc7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/525321 Tested-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Commit-Queue: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
@@ -566,6 +566,7 @@ These restrictions are not enforced for [Local Manifests].
|
||||
Attribute `groups`: List of additional groups to which all projects
|
||||
in the included manifest belong. This appends and recurses, meaning
|
||||
all projects in included manifests carry all parent include groups.
|
||||
This also applies to all extend-project elements in the included manifests.
|
||||
Same syntax as the corresponding element of `project`.
|
||||
|
||||
Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`)
|
||||
|
||||
@@ -627,7 +627,8 @@ restrictions are not enforced for [Local Manifests].
|
||||
.PP
|
||||
Attribute `groups`: List of additional groups to which all projects in the
|
||||
included manifest belong. This appends and recurses, meaning all projects in
|
||||
included manifests carry all parent include groups. Same syntax as the
|
||||
included manifests carry all parent include groups. This also applies to all
|
||||
extend\-project elements in the included manifests. Same syntax as the
|
||||
corresponding element of `project`.
|
||||
.PP
|
||||
Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`)
|
||||
|
||||
@@ -1335,7 +1335,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
||||
f"failed parsing included manifest {name}: {e}"
|
||||
)
|
||||
else:
|
||||
if parent_groups and node.nodeName == "project":
|
||||
if parent_groups and node.nodeName in (
|
||||
"project",
|
||||
"extend-project",
|
||||
):
|
||||
nodeGroups = parent_groups
|
||||
if node.hasAttribute("groups"):
|
||||
nodeGroups = (
|
||||
|
||||
@@ -488,6 +488,41 @@ class IncludeElementTests(ManifestParseTestCase):
|
||||
# Check level2 proj group not removed.
|
||||
self.assertIn("l2g1", proj.groups)
|
||||
|
||||
def test_group_levels_with_extend_project(self):
|
||||
root_m = self.manifest_dir / "root.xml"
|
||||
root_m.write_text(
|
||||
"""
|
||||
<manifest>
|
||||
<remote name="test-remote" fetch="http://localhost" />
|
||||
<default remote="test-remote" revision="refs/heads/main" />
|
||||
<include name="man1.xml" groups="top-group1" />
|
||||
<include name="man2.xml" groups="top-group2" />
|
||||
</manifest>
|
||||
"""
|
||||
)
|
||||
(self.manifest_dir / "man1.xml").write_text(
|
||||
"""
|
||||
<manifest>
|
||||
<project name="project1" path="project1" />
|
||||
</manifest>
|
||||
"""
|
||||
)
|
||||
(self.manifest_dir / "man2.xml").write_text(
|
||||
"""
|
||||
<manifest>
|
||||
<extend-project name="project1" groups="eg1" />
|
||||
</manifest>
|
||||
"""
|
||||
)
|
||||
include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m))
|
||||
proj = include_m.projects[0]
|
||||
# Check project has inherited group via project element.
|
||||
self.assertIn("top-group1", proj.groups)
|
||||
# Check project has inherited group via extend-project element.
|
||||
self.assertIn("top-group2", proj.groups)
|
||||
# Check project has set group via extend-project element.
|
||||
self.assertIn("eg1", proj.groups)
|
||||
|
||||
def test_allow_bad_name_from_user(self):
|
||||
"""Check handling of bad name attribute from the user's input."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user