mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
manifest: allow extend-project to override dest-branch and upstream
Bug: https://crbug.com/gerrit/16238 Change-Id: Id6eff34791525b3df690e160c911c0286331984b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/345144 Tested-by: Erik Elmeke <erik@haleytek.corp-partner.google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
1eddca8476
commit
4cdfdb7734
@ -105,6 +105,8 @@ following DTD:
|
|||||||
<!ATTLIST extend-project groups CDATA #IMPLIED>
|
<!ATTLIST extend-project groups CDATA #IMPLIED>
|
||||||
<!ATTLIST extend-project revision CDATA #IMPLIED>
|
<!ATTLIST extend-project revision CDATA #IMPLIED>
|
||||||
<!ATTLIST extend-project remote CDATA #IMPLIED>
|
<!ATTLIST extend-project remote CDATA #IMPLIED>
|
||||||
|
<!ATTLIST extend-project dest-branch CDATA #IMPLIED>
|
||||||
|
<!ATTLIST extend-project upstream CDATA #IMPLIED>
|
||||||
|
|
||||||
<!ELEMENT remove-project EMPTY>
|
<!ELEMENT remove-project EMPTY>
|
||||||
<!ATTLIST remove-project name CDATA #REQUIRED>
|
<!ATTLIST remove-project name CDATA #REQUIRED>
|
||||||
@ -423,6 +425,12 @@ project. Same syntax as the corresponding element of `project`.
|
|||||||
Attribute `remote`: If specified, overrides the remote of the original
|
Attribute `remote`: If specified, overrides the remote of the original
|
||||||
project. Same syntax as the corresponding element of `project`.
|
project. Same syntax as the corresponding element of `project`.
|
||||||
|
|
||||||
|
Attribute `dest-branch`: If specified, overrides the dest-branch of the original
|
||||||
|
project. Same syntax as the corresponding element of `project`.
|
||||||
|
|
||||||
|
Attribute `upstream`: If specified, overrides the upstream of the original
|
||||||
|
project. Same syntax as the corresponding element of `project`.
|
||||||
|
|
||||||
### Element annotation
|
### Element annotation
|
||||||
|
|
||||||
Zero or more annotation elements may be specified as children of a
|
Zero or more annotation elements may be specified as children of a
|
||||||
|
@ -1289,6 +1289,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
remote = self._default.remote
|
remote = self._default.remote
|
||||||
else:
|
else:
|
||||||
remote = self._get_remote(node)
|
remote = self._get_remote(node)
|
||||||
|
dest_branch = node.getAttribute('dest-branch')
|
||||||
|
upstream = node.getAttribute('upstream')
|
||||||
|
|
||||||
named_projects = self._projects[name]
|
named_projects = self._projects[name]
|
||||||
if dest_path and not path and len(named_projects) > 1:
|
if dest_path and not path and len(named_projects) > 1:
|
||||||
@ -1304,6 +1306,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
|
|
||||||
if remote_name:
|
if remote_name:
|
||||||
p.remote = remote.ToRemoteSpec(name)
|
p.remote = remote.ToRemoteSpec(name)
|
||||||
|
if dest_branch:
|
||||||
|
p.dest_branch = dest_branch
|
||||||
|
if upstream:
|
||||||
|
p.upstream = upstream
|
||||||
|
|
||||||
if dest_path:
|
if dest_path:
|
||||||
del self._paths[p.relpath]
|
del self._paths[p.relpath]
|
||||||
|
@ -874,3 +874,27 @@ class ExtendProjectElementTests(ManifestParseTestCase):
|
|||||||
else:
|
else:
|
||||||
self.assertEqual(manifest.projects[0].relpath, 'bar')
|
self.assertEqual(manifest.projects[0].relpath, 'bar')
|
||||||
self.assertEqual(manifest.projects[1].relpath, 'y')
|
self.assertEqual(manifest.projects[1].relpath, 'y')
|
||||||
|
|
||||||
|
def test_extend_project_dest_branch(self):
|
||||||
|
manifest = self.getXmlManifest("""
|
||||||
|
<manifest>
|
||||||
|
<remote name="default-remote" fetch="http://localhost" />
|
||||||
|
<default remote="default-remote" revision="refs/heads/main" dest-branch="foo" />
|
||||||
|
<project name="myproject" />
|
||||||
|
<extend-project name="myproject" dest-branch="bar" />
|
||||||
|
</manifest>
|
||||||
|
""")
|
||||||
|
self.assertEqual(len(manifest.projects), 1)
|
||||||
|
self.assertEqual(manifest.projects[0].dest_branch, 'bar')
|
||||||
|
|
||||||
|
def test_extend_project_upstream(self):
|
||||||
|
manifest = self.getXmlManifest("""
|
||||||
|
<manifest>
|
||||||
|
<remote name="default-remote" fetch="http://localhost" />
|
||||||
|
<default remote="default-remote" revision="refs/heads/main" />
|
||||||
|
<project name="myproject" />
|
||||||
|
<extend-project name="myproject" upstream="bar" />
|
||||||
|
</manifest>
|
||||||
|
""")
|
||||||
|
self.assertEqual(len(manifest.projects), 1)
|
||||||
|
self.assertEqual(manifest.projects[0].upstream, 'bar')
|
||||||
|
Loading…
Reference in New Issue
Block a user