diff options
| -rw-r--r-- | docs/manifest-format.md | 4 | ||||
| -rw-r--r-- | man/repo-manifest.1 | 4 | ||||
| -rw-r--r-- | manifest_xml.py | 16 | ||||
| -rw-r--r-- | tests/test_manifest_xml.py | 26 |
4 files changed, 40 insertions, 10 deletions
diff --git a/docs/manifest-format.md b/docs/manifest-format.md index b45b9180..bf1a0933 100644 --- a/docs/manifest-format.md +++ b/docs/manifest-format.md | |||
| @@ -579,7 +579,9 @@ This also applies to all extend-project elements in the included manifests. | |||
| 579 | Same syntax as the corresponding element of `project`. | 579 | Same syntax as the corresponding element of `project`. |
| 580 | 580 | ||
| 581 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) | 581 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) |
| 582 | default to which all projects in the included manifest belong. | 582 | default to which all projects in the included manifest belong. This recurses, |
| 583 | meaning it will apply to all projects in all manifests included as a result of | ||
| 584 | this element. | ||
| 583 | 585 | ||
| 584 | ## Local Manifests {#local-manifests} | 586 | ## Local Manifests {#local-manifests} |
| 585 | 587 | ||
diff --git a/man/repo-manifest.1 b/man/repo-manifest.1 index 38c728e6..74e44efd 100644 --- a/man/repo-manifest.1 +++ b/man/repo-manifest.1 | |||
| @@ -641,7 +641,9 @@ extend\-project elements in the included manifests. Same syntax as the | |||
| 641 | corresponding element of `project`. | 641 | corresponding element of `project`. |
| 642 | .PP | 642 | .PP |
| 643 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) | 643 | Attribute `revision`: Name of a Git branch (e.g. `main` or `refs/heads/main`) |
| 644 | default to which all projects in the included manifest belong. | 644 | default to which all projects in the included manifest belong. This recurses, |
| 645 | meaning it will apply to all projects in all manifests included as a result of | ||
| 646 | this element. | ||
| 645 | .PP | 647 | .PP |
| 646 | Local Manifests | 648 | Local Manifests |
| 647 | .PP | 649 | .PP |
diff --git a/manifest_xml.py b/manifest_xml.py index 2d476748..0e899e5a 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -1305,6 +1305,14 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1305 | 1305 | ||
| 1306 | nodes = [] | 1306 | nodes = [] |
| 1307 | for node in manifest.childNodes: | 1307 | for node in manifest.childNodes: |
| 1308 | if ( | ||
| 1309 | parent_node | ||
| 1310 | and node.nodeName in ("include", "project") | ||
| 1311 | and not node.hasAttribute("revision") | ||
| 1312 | ): | ||
| 1313 | node.setAttribute( | ||
| 1314 | "revision", parent_node.getAttribute("revision") | ||
| 1315 | ) | ||
| 1308 | if node.nodeName == "include": | 1316 | if node.nodeName == "include": |
| 1309 | name = self._reqatt(node, "name") | 1317 | name = self._reqatt(node, "name") |
| 1310 | if restrict_includes: | 1318 | if restrict_includes: |
| @@ -1349,14 +1357,6 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1349 | node.getAttribute("groups") | 1357 | node.getAttribute("groups") |
| 1350 | ) | 1358 | ) |
| 1351 | node.setAttribute("groups", ",".join(sorted(nodeGroups))) | 1359 | node.setAttribute("groups", ",".join(sorted(nodeGroups))) |
| 1352 | if ( | ||
| 1353 | parent_node | ||
| 1354 | and node.nodeName == "project" | ||
| 1355 | and not node.hasAttribute("revision") | ||
| 1356 | ): | ||
| 1357 | node.setAttribute( | ||
| 1358 | "revision", parent_node.getAttribute("revision") | ||
| 1359 | ) | ||
| 1360 | nodes.append(node) | 1360 | nodes.append(node) |
| 1361 | return nodes | 1361 | return nodes |
| 1362 | 1362 | ||
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 960d0cd8..0cd84f08 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
| @@ -422,11 +422,29 @@ class IncludeElementTests(ManifestParseTestCase): | |||
| 422 | (self.manifest_dir / "stable.xml").write_text( | 422 | (self.manifest_dir / "stable.xml").write_text( |
| 423 | """ | 423 | """ |
| 424 | <manifest> | 424 | <manifest> |
| 425 | <include name="man1.xml" /> | ||
| 426 | <include name="man2.xml" revision="stable-branch2" /> | ||
| 425 | <project name="stable-name1" path="stable-path1" /> | 427 | <project name="stable-name1" path="stable-path1" /> |
| 426 | <project name="stable-name2" path="stable-path2" revision="stable-branch2" /> | 428 | <project name="stable-name2" path="stable-path2" revision="stable-branch2" /> |
| 427 | </manifest> | 429 | </manifest> |
| 428 | """ | 430 | """ |
| 429 | ) | 431 | ) |
| 432 | (self.manifest_dir / "man1.xml").write_text( | ||
| 433 | """ | ||
| 434 | <manifest> | ||
| 435 | <project name="man1-name1" /> | ||
| 436 | <project name="man1-name2" revision="stable-branch3" /> | ||
| 437 | </manifest> | ||
| 438 | """ | ||
| 439 | ) | ||
| 440 | (self.manifest_dir / "man2.xml").write_text( | ||
| 441 | """ | ||
| 442 | <manifest> | ||
| 443 | <project name="man2-name1" /> | ||
| 444 | <project name="man2-name2" revision="stable-branch3" /> | ||
| 445 | </manifest> | ||
| 446 | """ | ||
| 447 | ) | ||
| 430 | include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m)) | 448 | include_m = manifest_xml.XmlManifest(str(self.repodir), str(root_m)) |
| 431 | for proj in include_m.projects: | 449 | for proj in include_m.projects: |
| 432 | if proj.name == "root-name1": | 450 | if proj.name == "root-name1": |
| @@ -441,6 +459,14 @@ class IncludeElementTests(ManifestParseTestCase): | |||
| 441 | if proj.name == "stable-name2": | 459 | if proj.name == "stable-name2": |
| 442 | # Check stable proj revision can override include node. | 460 | # Check stable proj revision can override include node. |
| 443 | self.assertEqual("stable-branch2", proj.revisionExpr) | 461 | self.assertEqual("stable-branch2", proj.revisionExpr) |
| 462 | if proj.name == "man1-name1": | ||
| 463 | self.assertEqual("stable-branch", proj.revisionExpr) | ||
| 464 | if proj.name == "man1-name2": | ||
| 465 | self.assertEqual("stable-branch3", proj.revisionExpr) | ||
| 466 | if proj.name == "man2-name1": | ||
| 467 | self.assertEqual("stable-branch2", proj.revisionExpr) | ||
| 468 | if proj.name == "man2-name2": | ||
| 469 | self.assertEqual("stable-branch3", proj.revisionExpr) | ||
| 444 | 470 | ||
| 445 | def test_group_levels(self): | 471 | def test_group_levels(self): |
| 446 | root_m = self.manifest_dir / "root.xml" | 472 | root_m = self.manifest_dir / "root.xml" |
