diff options
| -rw-r--r-- | docs/manifest-format.md | 8 | ||||
| -rw-r--r-- | manifest_xml.py | 6 | ||||
| -rw-r--r-- | tests/test_manifest_xml.py | 24 |
3 files changed, 38 insertions, 0 deletions
diff --git a/docs/manifest-format.md b/docs/manifest-format.md index 0d26296d..bcdf5a8e 100644 --- a/docs/manifest-format.md +++ b/docs/manifest-format.md | |||
| @@ -105,6 +105,8 @@ following DTD: | |||
| 105 | <!ATTLIST extend-project groups CDATA #IMPLIED> | 105 | <!ATTLIST extend-project groups CDATA #IMPLIED> |
| 106 | <!ATTLIST extend-project revision CDATA #IMPLIED> | 106 | <!ATTLIST extend-project revision CDATA #IMPLIED> |
| 107 | <!ATTLIST extend-project remote CDATA #IMPLIED> | 107 | <!ATTLIST extend-project remote CDATA #IMPLIED> |
| 108 | <!ATTLIST extend-project dest-branch CDATA #IMPLIED> | ||
| 109 | <!ATTLIST extend-project upstream CDATA #IMPLIED> | ||
| 108 | 110 | ||
| 109 | <!ELEMENT remove-project EMPTY> | 111 | <!ELEMENT remove-project EMPTY> |
| 110 | <!ATTLIST remove-project name CDATA #REQUIRED> | 112 | <!ATTLIST remove-project name CDATA #REQUIRED> |
| @@ -423,6 +425,12 @@ project. Same syntax as the corresponding element of `project`. | |||
| 423 | Attribute `remote`: If specified, overrides the remote of the original | 425 | Attribute `remote`: If specified, overrides the remote of the original |
| 424 | project. Same syntax as the corresponding element of `project`. | 426 | project. Same syntax as the corresponding element of `project`. |
| 425 | 427 | ||
| 428 | Attribute `dest-branch`: If specified, overrides the dest-branch of the original | ||
| 429 | project. Same syntax as the corresponding element of `project`. | ||
| 430 | |||
| 431 | Attribute `upstream`: If specified, overrides the upstream of the original | ||
| 432 | project. Same syntax as the corresponding element of `project`. | ||
| 433 | |||
| 426 | ### Element annotation | 434 | ### Element annotation |
| 427 | 435 | ||
| 428 | Zero or more annotation elements may be specified as children of a | 436 | Zero or more annotation elements may be specified as children of a |
diff --git a/manifest_xml.py b/manifest_xml.py index b7579d5d..129eb3f7 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -1289,6 +1289,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1289 | remote = self._default.remote | 1289 | remote = self._default.remote |
| 1290 | else: | 1290 | else: |
| 1291 | remote = self._get_remote(node) | 1291 | remote = self._get_remote(node) |
| 1292 | dest_branch = node.getAttribute('dest-branch') | ||
| 1293 | upstream = node.getAttribute('upstream') | ||
| 1292 | 1294 | ||
| 1293 | named_projects = self._projects[name] | 1295 | named_projects = self._projects[name] |
| 1294 | if dest_path and not path and len(named_projects) > 1: | 1296 | 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 | |||
| 1304 | 1306 | ||
| 1305 | if remote_name: | 1307 | if remote_name: |
| 1306 | p.remote = remote.ToRemoteSpec(name) | 1308 | p.remote = remote.ToRemoteSpec(name) |
| 1309 | if dest_branch: | ||
| 1310 | p.dest_branch = dest_branch | ||
| 1311 | if upstream: | ||
| 1312 | p.upstream = upstream | ||
| 1307 | 1313 | ||
| 1308 | if dest_path: | 1314 | if dest_path: |
| 1309 | del self._paths[p.relpath] | 1315 | del self._paths[p.relpath] |
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 48403c0d..e181b642 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
| @@ -874,3 +874,27 @@ class ExtendProjectElementTests(ManifestParseTestCase): | |||
| 874 | else: | 874 | else: |
| 875 | self.assertEqual(manifest.projects[0].relpath, 'bar') | 875 | self.assertEqual(manifest.projects[0].relpath, 'bar') |
| 876 | self.assertEqual(manifest.projects[1].relpath, 'y') | 876 | self.assertEqual(manifest.projects[1].relpath, 'y') |
| 877 | |||
| 878 | def test_extend_project_dest_branch(self): | ||
| 879 | manifest = self.getXmlManifest(""" | ||
| 880 | <manifest> | ||
| 881 | <remote name="default-remote" fetch="http://localhost" /> | ||
| 882 | <default remote="default-remote" revision="refs/heads/main" dest-branch="foo" /> | ||
| 883 | <project name="myproject" /> | ||
| 884 | <extend-project name="myproject" dest-branch="bar" /> | ||
| 885 | </manifest> | ||
| 886 | """) | ||
| 887 | self.assertEqual(len(manifest.projects), 1) | ||
| 888 | self.assertEqual(manifest.projects[0].dest_branch, 'bar') | ||
| 889 | |||
| 890 | def test_extend_project_upstream(self): | ||
| 891 | manifest = self.getXmlManifest(""" | ||
| 892 | <manifest> | ||
| 893 | <remote name="default-remote" fetch="http://localhost" /> | ||
| 894 | <default remote="default-remote" revision="refs/heads/main" /> | ||
| 895 | <project name="myproject" /> | ||
| 896 | <extend-project name="myproject" upstream="bar" /> | ||
| 897 | </manifest> | ||
| 898 | """) | ||
| 899 | self.assertEqual(len(manifest.projects), 1) | ||
| 900 | self.assertEqual(manifest.projects[0].upstream, 'bar') | ||
