summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2026-01-14 22:14:28 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-01-15 10:27:32 -0800
commit3c0e67bbc5f7c3849919735db4bfd7e66190f80c (patch)
tree70298691b368bfe0b6fffbb03e76e425440cbbb3
parent3b7b20ac1d3abe7d2ac37e2040326aa1051b1336 (diff)
downloadgit-repo-3c0e67bbc5f7c3849919735db4bfd7e66190f80c.tar.gz
manifest_xml: prevent extend-project from inheriting local groups
When extending a project in a local manifest, the project inherits the `local:` group. This causes the superproject override logic (which omits projects with `local:` groups) to incorrectly exclude the project from the override manifest. This leads to "extend-project element specifies non-existent project" errors during sync reload. Fix this by stripping `local:` groups from extended projects, ensuring they remain visible to superproject overrides while still allowing other inherited groups to persist. Bug: 470374343 Change-Id: I1a057ebffebc11a19dc14dde7cc13b9f18cdd0a3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/543222 Reviewed-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
-rw-r--r--manifest_xml.py8
-rw-r--r--tests/test_manifest_xml.py27
2 files changed, 35 insertions, 0 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 7987061d6..6989aad53 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -1487,6 +1487,14 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
1487 continue 1487 continue
1488 if groups: 1488 if groups:
1489 p.groups |= groups 1489 p.groups |= groups
1490 # Drop local groups so we don't mistakenly omit this
1491 # project from the superproject override manifest.
1492 p.groups = {
1493 g
1494 for g in p.groups
1495 if not g.startswith(LOCAL_MANIFEST_GROUP_PREFIX)
1496 }
1497
1490 if revision: 1498 if revision:
1491 if base_revision: 1499 if base_revision:
1492 if p.revisionExpr != base_revision: 1500 if p.revisionExpr != base_revision:
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 039921f65..97fea3da3 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -549,6 +549,33 @@ class IncludeElementTests(ManifestParseTestCase):
549 # Check project has set group via extend-project element. 549 # Check project has set group via extend-project element.
550 self.assertIn("eg1", proj.groups) 550 self.assertIn("eg1", proj.groups)
551 551
552 def test_extend_project_does_not_inherit_local_groups(self):
553 """Check that extend-project does not inherit local groups."""
554 root_m = self.manifest_dir / "root.xml"
555 root_m.write_text(
556 """
557<manifest>
558 <remote name="test-remote" fetch="http://localhost" />
559 <default remote="test-remote" revision="refs/heads/main" />
560 <project name="project1" path="project1" />
561 <include name="man1.xml" groups="g1,local:g2" />
562</manifest>
563"""
564 )
565 (self.manifest_dir / "man1.xml").write_text(
566 """
567<manifest>
568 <extend-project name="project1" groups="g3" />
569</manifest>
570"""
571 )
572 include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m))
573 proj = include_m.projects[0]
574
575 self.assertIn("g1", proj.groups)
576 self.assertNotIn("local:g2", proj.groups)
577 self.assertIn("g3", proj.groups)
578
552 def test_allow_bad_name_from_user(self): 579 def test_allow_bad_name_from_user(self):
553 """Check handling of bad name attribute from the user's input.""" 580 """Check handling of bad name attribute from the user's input."""
554 581