summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShuchuan Zeng <zengshuchuan@allwinnertech.com>2023-04-18 10:36:50 +0800
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-05 03:40:28 +0000
commit3e3340d94f8a680156ceaa81faca1c3b8863c6ac (patch)
tree93bcf5c0d43e2a9fc2c4c88703abe3e185cbeec8 /tests
parentedcaa94ca86d29c1ea106eddac837f4a699379ba (diff)
downloadgit-repo-3e3340d94f8a680156ceaa81faca1c3b8863c6ac.tar.gz
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, ``` <include name="include.xml" revision="r1" /> ``` and the include.xml has some projects, ``` <project path="project1_path" name="project1_name" revision="r2" /> <project path="project2_path" name="project2_name" /> ``` With this change, the final manifest will have revision="r1" for project2. ``` <project name="project1_name" path="project1_path" revision="r2" /> <project name="project2_name" path="project2_path" revision="r1" /> ``` 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 <vapier@google.com> Commit-Queue: Shuchuan Zeng <zengshuchuan@allwinnertech.com> Tested-by: Shuchuan Zeng <zengshuchuan@allwinnertech.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_manifest_xml.py39
1 files changed, 39 insertions, 0 deletions
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):
389class IncludeElementTests(ManifestParseTestCase): 389class IncludeElementTests(ManifestParseTestCase):
390 """Tests for <include>.""" 390 """Tests for <include>."""
391 391
392 def test_revision_default(self):
393 """Check handling of revision attribute."""
394 root_m = os.path.join(self.manifest_dir, "root.xml")
395 with open(root_m, "w") as fp:
396 fp.write(
397 """
398<manifest>
399 <remote name="test-remote" fetch="http://localhost" />
400 <default remote="test-remote" revision="refs/heads/main" />
401 <include name="stable.xml" revision="stable-branch" />
402 <project name="root-name1" path="root-path1" />
403 <project name="root-name2" path="root-path2" />
404</manifest>
405"""
406 )
407 with open(os.path.join(self.manifest_dir, "stable.xml"), "w") as fp:
408 fp.write(
409 """
410<manifest>
411 <project name="stable-name1" path="stable-path1" />
412 <project name="stable-name2" path="stable-path2" revision="stable-branch2" />
413</manifest>
414"""
415 )
416 include_m = manifest_xml.XmlManifest(self.repodir, root_m)
417 for proj in include_m.projects:
418 if proj.name == "root-name1":
419 # Check include revision not set on root level proj.
420 self.assertNotEqual("stable-branch", proj.revisionExpr)
421 if proj.name == "root-name2":
422 # Check root proj revision not removed.
423 self.assertEqual("refs/heads/main", proj.revisionExpr)
424 if proj.name == "stable-name1":
425 # Check stable proj has inherited revision include node.
426 self.assertEqual("stable-branch", proj.revisionExpr)
427 if proj.name == "stable-name2":
428 # Check stable proj revision can override include node.
429 self.assertEqual("stable-branch2", proj.revisionExpr)
430
392 def test_group_levels(self): 431 def test_group_levels(self):
393 root_m = os.path.join(self.manifest_dir, "root.xml") 432 root_m = os.path.join(self.manifest_dir, "root.xml")
394 with open(root_m, "w") as fp: 433 with open(root_m, "w") as fp: