From 3e3340d94f8a680156ceaa81faca1c3b8863c6ac Mon Sep 17 00:00:00 2001 From: Shuchuan Zeng Date: Tue, 18 Apr 2023 10:36:50 +0800 Subject: manifest: add support for revision in include Attribute groups can now be added to manifest include, thus all projects in an included manifest file can easily modify default branch without modifying all projects in that manifest file. For example, the main manifest.xml has an include node contain revision attribute, ``` ``` and the include.xml has some projects, ``` ``` With this change, the final manifest will have revision="r1" for project2. ``` ``` Test: added unit tests to cover the inheritance Change-Id: I4b8547a7198610ec3a3c6aeb2136e0c0f3557df0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/369714 Reviewed-by: Mike Frysinger Commit-Queue: Shuchuan Zeng Tested-by: Shuchuan Zeng --- tests/test_manifest_xml.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 648acde8..ef511055 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -389,6 +389,45 @@ class XmlManifestTests(ManifestParseTestCase): class IncludeElementTests(ManifestParseTestCase): """Tests for .""" + def test_revision_default(self): + """Check handling of revision attribute.""" + root_m = os.path.join(self.manifest_dir, "root.xml") + with open(root_m, "w") as fp: + fp.write( + """ + + + + + + + +""" + ) + with open(os.path.join(self.manifest_dir, "stable.xml"), "w") as fp: + fp.write( + """ + + + + +""" + ) + include_m = manifest_xml.XmlManifest(self.repodir, root_m) + for proj in include_m.projects: + if proj.name == "root-name1": + # Check include revision not set on root level proj. + self.assertNotEqual("stable-branch", proj.revisionExpr) + if proj.name == "root-name2": + # Check root proj revision not removed. + self.assertEqual("refs/heads/main", proj.revisionExpr) + if proj.name == "stable-name1": + # Check stable proj has inherited revision include node. + self.assertEqual("stable-branch", proj.revisionExpr) + if proj.name == "stable-name2": + # Check stable proj revision can override include node. + self.assertEqual("stable-branch2", proj.revisionExpr) + def test_group_levels(self): root_m = os.path.join(self.manifest_dir, "root.xml") with open(root_m, "w") as fp: -- cgit v1.2.3-54-g00ecf