summaryrefslogtreecommitdiff
path: root/tests/test_manifest_xml.py
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2021-09-26 23:20:32 -0700
committerXin Li <delphij@google.com>2021-09-27 06:36:05 +0000
commite0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6 (patch)
tree7759c55cdbe045de3974be17bc3a5557d42619db /tests/test_manifest_xml.py
parentd669d2dee5bd7986593d5df1dd8a736778501bbf (diff)
downloadgit-repo-e0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6.tar.gz
git-repo-e0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6.zip
superproject: support a new revision attribute.
Tested: $ ./run_tests Verified that a manifest that specified superproject revision would use the specified revision, and superproject will use the default revision. Note that this is a slight behavior change from earlier repo versions, which would always use the branch name of the manifest itself. However, the new behavior would be more consisitent with regular "project" element and would allow superproject be used even if it is not enabled for the particular manifest branch, so we have decided to make the change as it would provide more flexibility and better matches what other elements would do. Bug: [google internal] b/187868160 Change-Id: I35255ee347aff6e65179f7879d52931f168b477e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/317643 Tested-by: Xin Li <delphij@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r--tests/test_manifest_xml.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 20459d1d7..ce4225366 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -572,6 +572,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
self.assertEqual(manifest.superproject['name'], 'superproject')
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
self.assertEqual(
sort_attributes(manifest.ToXml().toxml()),
'<?xml version="1.0" ?><manifest>'
@@ -580,6 +581,72 @@ class SuperProjectElementTests(ManifestParseTestCase):
'<superproject name="superproject"/>'
'</manifest>')
+ def test_superproject_revision(self):
+ """Check superproject settings with a different revision attribute"""
+ self.maxDiff = None
+ manifest = self.getXmlManifest("""
+<manifest>
+ <remote name="test-remote" fetch="http://localhost" />
+ <default remote="test-remote" revision="refs/heads/main" />
+ <superproject name="superproject" revision="refs/heads/stable" />
+</manifest>
+""")
+ self.assertEqual(manifest.superproject['name'], 'superproject')
+ self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
+ self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
+ self.assertEqual(
+ sort_attributes(manifest.ToXml().toxml()),
+ '<?xml version="1.0" ?><manifest>'
+ '<remote fetch="http://localhost" name="test-remote"/>'
+ '<default remote="test-remote" revision="refs/heads/main"/>'
+ '<superproject name="superproject" revision="refs/heads/stable"/>'
+ '</manifest>')
+
+ def test_superproject_revision_default_negative(self):
+ """Check superproject settings with a same revision attribute"""
+ self.maxDiff = None
+ manifest = self.getXmlManifest("""
+<manifest>
+ <remote name="test-remote" fetch="http://localhost" />
+ <default remote="test-remote" revision="refs/heads/stable" />
+ <superproject name="superproject" revision="refs/heads/stable" />
+</manifest>
+""")
+ self.assertEqual(manifest.superproject['name'], 'superproject')
+ self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
+ self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
+ self.assertEqual(
+ sort_attributes(manifest.ToXml().toxml()),
+ '<?xml version="1.0" ?><manifest>'
+ '<remote fetch="http://localhost" name="test-remote"/>'
+ '<default remote="test-remote" revision="refs/heads/stable"/>'
+ '<superproject name="superproject"/>'
+ '</manifest>')
+
+ def test_superproject_revision_remote(self):
+ """Check superproject settings with a same revision attribute"""
+ self.maxDiff = None
+ manifest = self.getXmlManifest("""
+<manifest>
+ <remote name="test-remote" fetch="http://localhost" revision="refs/heads/main" />
+ <default remote="test-remote" />
+ <superproject name="superproject" revision="refs/heads/stable" />
+</manifest>
+""")
+ self.assertEqual(manifest.superproject['name'], 'superproject')
+ self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
+ self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
+ self.assertEqual(
+ sort_attributes(manifest.ToXml().toxml()),
+ '<?xml version="1.0" ?><manifest>'
+ '<remote fetch="http://localhost" name="test-remote" revision="refs/heads/main"/>'
+ '<default remote="test-remote"/>'
+ '<superproject name="superproject" revision="refs/heads/stable"/>'
+ '</manifest>')
+
def test_remote(self):
"""Check superproject settings with a remote."""
manifest = self.getXmlManifest("""
@@ -593,6 +660,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
self.assertEqual(manifest.superproject['name'], 'platform/superproject')
self.assertEqual(manifest.superproject['remote'].name, 'superproject-remote')
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/platform/superproject')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
self.assertEqual(
sort_attributes(manifest.ToXml().toxml()),
'<?xml version="1.0" ?><manifest>'
@@ -613,6 +681,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
""")
self.assertEqual(manifest.superproject['name'], 'superproject')
self.assertEqual(manifest.superproject['remote'].name, 'default-remote')
+ self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
self.assertEqual(
sort_attributes(manifest.ToXml().toxml()),
'<?xml version="1.0" ?><manifest>'