mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-23 07:16:21 +00:00
manifest: set revisionId as revision attribute it it is not being set in ToXml.
As we were testing superproject setting revisionId attribute to SHA and reloading the manifest, we found out revisionId attribute is not being saved. Made the change to save the revisionId if it is not being saved. Tested the code with the following commands. $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I95fdf655b19648ad3e9aba10b9bed8bb9439deb6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296182 Reviewed-by: Ian Kasprzak <iankaz@google.com>
This commit is contained in:
parent
0286e31ec7
commit
b5c5a5e068
@ -403,6 +403,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr
|
revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr
|
||||||
if not revision or revision != p.revisionExpr:
|
if not revision or revision != p.revisionExpr:
|
||||||
e.setAttribute('revision', p.revisionExpr)
|
e.setAttribute('revision', p.revisionExpr)
|
||||||
|
elif p.revisionId:
|
||||||
|
e.setAttribute('revision', p.revisionId)
|
||||||
if (p.upstream and (p.upstream != p.revisionExpr or
|
if (p.upstream and (p.upstream != p.revisionExpr or
|
||||||
p.upstream != d.upstreamExpr)):
|
p.upstream != d.upstreamExpr)):
|
||||||
e.setAttribute('upstream', p.upstream)
|
e.setAttribute('upstream', p.upstream)
|
||||||
|
@ -327,6 +327,26 @@ class XmlManifestTests(unittest.TestCase):
|
|||||||
result['extras'],
|
result['extras'],
|
||||||
['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path'])
|
['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path'])
|
||||||
|
|
||||||
|
def test_project_set_revision_id(self):
|
||||||
|
"""Check setting of project's revisionId."""
|
||||||
|
manifest = self.getXmlManifest("""
|
||||||
|
<manifest>
|
||||||
|
<remote name="default-remote" fetch="http://localhost" />
|
||||||
|
<default remote="default-remote" revision="refs/heads/main" />
|
||||||
|
<project name="test-name"/>
|
||||||
|
</manifest>
|
||||||
|
""")
|
||||||
|
self.assertEqual(len(manifest.projects), 1)
|
||||||
|
project = manifest.projects[0]
|
||||||
|
project.SetRevisionId('ABCDEF')
|
||||||
|
self.assertEqual(
|
||||||
|
manifest.ToXml().toxml(),
|
||||||
|
'<?xml version="1.0" ?><manifest>' +
|
||||||
|
'<remote name="default-remote" fetch="http://localhost"/>' +
|
||||||
|
'<default remote="default-remote" revision="refs/heads/main"/>' +
|
||||||
|
'<project name="test-name" revision="ABCDEF"/>' +
|
||||||
|
'</manifest>')
|
||||||
|
|
||||||
def test_include_levels(self):
|
def test_include_levels(self):
|
||||||
root_m = os.path.join(self.manifest_dir, 'root.xml')
|
root_m = os.path.join(self.manifest_dir, 'root.xml')
|
||||||
with open(root_m, 'w') as fp:
|
with open(root_m, 'w') as fp:
|
||||||
|
Loading…
Reference in New Issue
Block a user