Skip to content

Commit 47c24b5

Browse files
Peter KjellerstedtLUCI
authored andcommitted
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 <[email protected]> Commit-Queue: Peter Kjellerstedt <[email protected]> Reviewed-by: Gavin Mak <[email protected]> Reviewed-by: Mike Frysinger <[email protected]>
1 parent be33106 commit 47c24b5

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

docs/manifest-format.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ These restrictions are not enforced for [Local Manifests].
566566
Attribute `groups`: List of additional groups to which all projects
567567
in the included manifest belong. This appends and recurses, meaning
568568
all projects in included manifests carry all parent include groups.
569+
This also applies to all extend-project elements in the included manifests.
569570
Same syntax as the corresponding element of `project`.
570571

571572
Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`)

man/repo-manifest.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ restrictions are not enforced for [Local Manifests].
627627
.PP
628628
Attribute `groups`: List of additional groups to which all projects in the
629629
included manifest belong. This appends and recurses, meaning all projects in
630-
included manifests carry all parent include groups. Same syntax as the
630+
included manifests carry all parent include groups. This also applies to all
631+
extend\-project elements in the included manifests. Same syntax as the
631632
corresponding element of `project`.
632633
.PP
633634
Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`)

manifest_xml.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,10 @@ def _ParseManifestXml(
13351335
f"failed parsing included manifest {name}: {e}"
13361336
)
13371337
else:
1338-
if parent_groups and node.nodeName == "project":
1338+
if parent_groups and node.nodeName in (
1339+
"project",
1340+
"extend-project",
1341+
):
13391342
nodeGroups = parent_groups
13401343
if node.hasAttribute("groups"):
13411344
nodeGroups = (

tests/test_manifest_xml.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,41 @@ def test_group_levels(self):
488488
# Check level2 proj group not removed.
489489
self.assertIn("l2g1", proj.groups)
490490

491+
def test_group_levels_with_extend_project(self):
492+
root_m = self.manifest_dir / "root.xml"
493+
root_m.write_text(
494+
"""
495+
<manifest>
496+
<remote name="test-remote" fetch="http://localhost" />
497+
<default remote="test-remote" revision="refs/heads/main" />
498+
<include name="man1.xml" groups="top-group1" />
499+
<include name="man2.xml" groups="top-group2" />
500+
</manifest>
501+
"""
502+
)
503+
(self.manifest_dir / "man1.xml").write_text(
504+
"""
505+
<manifest>
506+
<project name="project1" path="project1" />
507+
</manifest>
508+
"""
509+
)
510+
(self.manifest_dir / "man2.xml").write_text(
511+
"""
512+
<manifest>
513+
<extend-project name="project1" groups="eg1" />
514+
</manifest>
515+
"""
516+
)
517+
include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m))
518+
proj = include_m.projects[0]
519+
# Check project has inherited group via project element.
520+
self.assertIn("top-group1", proj.groups)
521+
# Check project has inherited group via extend-project element.
522+
self.assertIn("top-group2", proj.groups)
523+
# Check project has set group via extend-project element.
524+
self.assertIn("eg1", proj.groups)
525+
491526
def test_allow_bad_name_from_user(self):
492527
"""Check handling of bad name attribute from the user's input."""
493528

0 commit comments

Comments
 (0)