diff options
-rw-r--r-- | manifest_xml.py | 2 | ||||
-rw-r--r-- | tests/test_manifest_xml.py | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index eb8a98cc..e32551c8 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -403,6 +403,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
403 | revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr | 403 | revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr |
404 | if not revision or revision != p.revisionExpr: | 404 | if not revision or revision != p.revisionExpr: |
405 | e.setAttribute('revision', p.revisionExpr) | 405 | e.setAttribute('revision', p.revisionExpr) |
406 | elif p.revisionId: | ||
407 | e.setAttribute('revision', p.revisionId) | ||
406 | if (p.upstream and (p.upstream != p.revisionExpr or | 408 | if (p.upstream and (p.upstream != p.revisionExpr or |
407 | p.upstream != d.upstreamExpr)): | 409 | p.upstream != d.upstreamExpr)): |
408 | e.setAttribute('upstream', p.upstream) | 410 | e.setAttribute('upstream', p.upstream) |
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 370eb4f5..5fd242fc 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -327,6 +327,26 @@ class XmlManifestTests(unittest.TestCase): | |||
327 | result['extras'], | 327 | result['extras'], |
328 | ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) | 328 | ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) |
329 | 329 | ||
330 | def test_project_set_revision_id(self): | ||
331 | """Check setting of project's revisionId.""" | ||
332 | manifest = self.getXmlManifest(""" | ||
333 | <manifest> | ||
334 | <remote name="default-remote" fetch="http://localhost" /> | ||
335 | <default remote="default-remote" revision="refs/heads/main" /> | ||
336 | <project name="test-name"/> | ||
337 | </manifest> | ||
338 | """) | ||
339 | self.assertEqual(len(manifest.projects), 1) | ||
340 | project = manifest.projects[0] | ||
341 | project.SetRevisionId('ABCDEF') | ||
342 | self.assertEqual( | ||
343 | manifest.ToXml().toxml(), | ||
344 | '<?xml version="1.0" ?><manifest>' + | ||
345 | '<remote name="default-remote" fetch="http://localhost"/>' + | ||
346 | '<default remote="default-remote" revision="refs/heads/main"/>' + | ||
347 | '<project name="test-name" revision="ABCDEF"/>' + | ||
348 | '</manifest>') | ||
349 | |||
330 | def test_include_levels(self): | 350 | def test_include_levels(self): |
331 | root_m = os.path.join(self.manifest_dir, 'root.xml') | 351 | root_m = os.path.join(self.manifest_dir, 'root.xml') |
332 | with open(root_m, 'w') as fp: | 352 | with open(root_m, 'w') as fp: |