diff options
| -rw-r--r-- | docs/manifest-format.md | 1 | ||||
| -rw-r--r-- | man/repo-manifest.1 | 3 | ||||
| -rw-r--r-- | manifest_xml.py | 5 | ||||
| -rw-r--r-- | tests/test_manifest_xml.py | 35 |
4 files changed, 42 insertions, 2 deletions
diff --git a/docs/manifest-format.md b/docs/manifest-format.md index 06d370a3..d1a11cc9 100644 --- a/docs/manifest-format.md +++ b/docs/manifest-format.md | |||
| @@ -566,6 +566,7 @@ These restrictions are not enforced for [Local Manifests]. | |||
| 566 | Attribute `groups`: List of additional groups to which all projects | 566 | Attribute `groups`: List of additional groups to which all projects |
| 567 | in the included manifest belong. This appends and recurses, meaning | 567 | in the included manifest belong. This appends and recurses, meaning |
| 568 | all projects in included manifests carry all parent include groups. | 568 | all projects in included manifests carry all parent include groups. |
| 569 | This also applies to all extend-project elements in the included manifests. | ||
| 569 | Same syntax as the corresponding element of `project`. | 570 | Same syntax as the corresponding element of `project`. |
| 570 | 571 | ||
| 571 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) | 572 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) |
diff --git a/man/repo-manifest.1 b/man/repo-manifest.1 index 4658b1e9..df3943ce 100644 --- a/man/repo-manifest.1 +++ b/man/repo-manifest.1 | |||
| @@ -627,7 +627,8 @@ restrictions are not enforced for [Local Manifests]. | |||
| 627 | .PP | 627 | .PP |
| 628 | Attribute `groups`: List of additional groups to which all projects in the | 628 | Attribute `groups`: List of additional groups to which all projects in the |
| 629 | included manifest belong. This appends and recurses, meaning all projects in | 629 | 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 | ||
| 631 | corresponding element of `project`. | 632 | corresponding element of `project`. |
| 632 | .PP | 633 | .PP |
| 633 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) | 634 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) |
diff --git a/manifest_xml.py b/manifest_xml.py index 5e0b53b9..33a55282 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -1335,7 +1335,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1335 | f"failed parsing included manifest {name}: {e}" | 1335 | f"failed parsing included manifest {name}: {e}" |
| 1336 | ) | 1336 | ) |
| 1337 | else: | 1337 | else: |
| 1338 | if parent_groups and node.nodeName == "project": | 1338 | if parent_groups and node.nodeName in ( |
| 1339 | "project", | ||
| 1340 | "extend-project", | ||
| 1341 | ): | ||
| 1339 | nodeGroups = parent_groups | 1342 | nodeGroups = parent_groups |
| 1340 | if node.hasAttribute("groups"): | 1343 | if node.hasAttribute("groups"): |
| 1341 | nodeGroups = ( | 1344 | nodeGroups = ( |
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index c1fed2bf..d4bf76a9 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
| @@ -488,6 +488,41 @@ class IncludeElementTests(ManifestParseTestCase): | |||
| 488 | # Check level2 proj group not removed. | 488 | # Check level2 proj group not removed. |
| 489 | self.assertIn("l2g1", proj.groups) | 489 | self.assertIn("l2g1", proj.groups) |
| 490 | 490 | ||
| 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 | |||
| 491 | def test_allow_bad_name_from_user(self): | 526 | def test_allow_bad_name_from_user(self): |
| 492 | """Check handling of bad name attribute from the user's input.""" | 527 | """Check handling of bad name attribute from the user's input.""" |
| 493 | 528 | ||
