diff options
author | YOUNG HO CHA <ganadist@gmail.com> | 2018-02-14 16:57:31 +0900 |
---|---|---|
committer | YOUNG HO CHA <ganadist@gmail.com> | 2018-02-14 16:57:41 +0900 |
commit | a32c92c206ad02f473cfa9558d4eac8f0fc738a8 (patch) | |
tree | 64e14a141835c22da1585425d62d84ca3cf573f3 | |
parent | 685320b000c0683421a460d1c9a33ae9d73cc706 (diff) | |
download | git-repo-a32c92c206ad02f473cfa9558d4eac8f0fc738a8.tar.gz |
implement optional 'sync-tags' in the manifest file
Allow the 'default' and 'project' element in the manifest
file to apply "--no-tags" option equivalent.
Change-Id: I7e0f8c17a0e25cca744d45df049076d203c52ff5
Signed-off-by: YOUNG HO CHA <ganadist@gmail.com>
-rw-r--r-- | docs/manifest-format.txt | 6 | ||||
-rw-r--r-- | manifest_xml.py | 20 | ||||
-rw-r--r-- | project.py | 8 |
3 files changed, 34 insertions, 0 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index 77784099..0e6cbe32 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
@@ -47,6 +47,7 @@ following DTD: | |||
47 | <!ATTLIST default sync-j CDATA #IMPLIED> | 47 | <!ATTLIST default sync-j CDATA #IMPLIED> |
48 | <!ATTLIST default sync-c CDATA #IMPLIED> | 48 | <!ATTLIST default sync-c CDATA #IMPLIED> |
49 | <!ATTLIST default sync-s CDATA #IMPLIED> | 49 | <!ATTLIST default sync-s CDATA #IMPLIED> |
50 | <!ATTLIST default sync-tags CDATA #IMPLIED> | ||
50 | 51 | ||
51 | <!ELEMENT manifest-server EMPTY> | 52 | <!ELEMENT manifest-server EMPTY> |
52 | <!ATTLIST manifest-server url CDATA #REQUIRED> | 53 | <!ATTLIST manifest-server url CDATA #REQUIRED> |
@@ -63,6 +64,7 @@ following DTD: | |||
63 | <!ATTLIST project groups CDATA #IMPLIED> | 64 | <!ATTLIST project groups CDATA #IMPLIED> |
64 | <!ATTLIST project sync-c CDATA #IMPLIED> | 65 | <!ATTLIST project sync-c CDATA #IMPLIED> |
65 | <!ATTLIST project sync-s CDATA #IMPLIED> | 66 | <!ATTLIST project sync-s CDATA #IMPLIED> |
67 | <!ATTLIST default sync-tags CDATA #IMPLIED> | ||
66 | <!ATTLIST project upstream CDATA #IMPLIED> | 68 | <!ATTLIST project upstream CDATA #IMPLIED> |
67 | <!ATTLIST project clone-depth CDATA #IMPLIED> | 69 | <!ATTLIST project clone-depth CDATA #IMPLIED> |
68 | <!ATTLIST project force-path CDATA #IMPLIED> | 70 | <!ATTLIST project force-path CDATA #IMPLIED> |
@@ -170,6 +172,10 @@ their own will use this value. | |||
170 | 172 | ||
171 | Attribute `sync-s`: Set to true to also sync sub-projects. | 173 | Attribute `sync-s`: Set to true to also sync sub-projects. |
172 | 174 | ||
175 | Attribute `sync-tags`: Set to false to only sync the given Git | ||
176 | branch (specified in the `revision` attribute) rather than | ||
177 | the other ref tags. | ||
178 | |||
173 | 179 | ||
174 | Element manifest-server | 180 | Element manifest-server |
175 | ----------------------- | 181 | ----------------------- |
diff --git a/manifest_xml.py b/manifest_xml.py index 9b5d7847..0654222e 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -63,6 +63,7 @@ class _Default(object): | |||
63 | sync_j = 1 | 63 | sync_j = 1 |
64 | sync_c = False | 64 | sync_c = False |
65 | sync_s = False | 65 | sync_s = False |
66 | sync_tags = True | ||
66 | 67 | ||
67 | def __eq__(self, other): | 68 | def __eq__(self, other): |
68 | return self.__dict__ == other.__dict__ | 69 | return self.__dict__ == other.__dict__ |
@@ -238,6 +239,9 @@ class XmlManifest(object): | |||
238 | if d.sync_s: | 239 | if d.sync_s: |
239 | have_default = True | 240 | have_default = True |
240 | e.setAttribute('sync-s', 'true') | 241 | e.setAttribute('sync-s', 'true') |
242 | if not d.sync_tags: | ||
243 | have_default = True | ||
244 | e.setAttribute('sync-tags', 'false') | ||
241 | if have_default: | 245 | if have_default: |
242 | root.appendChild(e) | 246 | root.appendChild(e) |
243 | root.appendChild(doc.createTextNode('')) | 247 | root.appendChild(doc.createTextNode('')) |
@@ -327,6 +331,9 @@ class XmlManifest(object): | |||
327 | if p.sync_s: | 331 | if p.sync_s: |
328 | e.setAttribute('sync-s', 'true') | 332 | e.setAttribute('sync-s', 'true') |
329 | 333 | ||
334 | if not p.sync_tags: | ||
335 | e.setAttribute('sync-tags', 'false') | ||
336 | |||
330 | if p.clone_depth: | 337 | if p.clone_depth: |
331 | e.setAttribute('clone-depth', str(p.clone_depth)) | 338 | e.setAttribute('clone-depth', str(p.clone_depth)) |
332 | 339 | ||
@@ -702,6 +709,12 @@ class XmlManifest(object): | |||
702 | d.sync_s = False | 709 | d.sync_s = False |
703 | else: | 710 | else: |
704 | d.sync_s = sync_s.lower() in ("yes", "true", "1") | 711 | d.sync_s = sync_s.lower() in ("yes", "true", "1") |
712 | |||
713 | sync_tags = node.getAttribute('sync-tags') | ||
714 | if not sync_tags: | ||
715 | d.sync_tags = True | ||
716 | else: | ||
717 | d.sync_tags = sync_tags.lower() in ("yes", "true", "1") | ||
705 | return d | 718 | return d |
706 | 719 | ||
707 | def _ParseNotice(self, node): | 720 | def _ParseNotice(self, node): |
@@ -796,6 +809,12 @@ class XmlManifest(object): | |||
796 | else: | 809 | else: |
797 | sync_s = sync_s.lower() in ("yes", "true", "1") | 810 | sync_s = sync_s.lower() in ("yes", "true", "1") |
798 | 811 | ||
812 | sync_tags = node.getAttribute('sync-tags') | ||
813 | if not sync_tags: | ||
814 | sync_tags = self._default.sync_tags | ||
815 | else: | ||
816 | sync_tags = sync_tags.lower() in ("yes", "true", "1") | ||
817 | |||
799 | clone_depth = node.getAttribute('clone-depth') | 818 | clone_depth = node.getAttribute('clone-depth') |
800 | if clone_depth: | 819 | if clone_depth: |
801 | try: | 820 | try: |
@@ -841,6 +860,7 @@ class XmlManifest(object): | |||
841 | groups = groups, | 860 | groups = groups, |
842 | sync_c = sync_c, | 861 | sync_c = sync_c, |
843 | sync_s = sync_s, | 862 | sync_s = sync_s, |
863 | sync_tags = sync_tags, | ||
844 | clone_depth = clone_depth, | 864 | clone_depth = clone_depth, |
845 | upstream = upstream, | 865 | upstream = upstream, |
846 | parent = parent, | 866 | parent = parent, |
@@ -660,6 +660,7 @@ class Project(object): | |||
660 | groups=None, | 660 | groups=None, |
661 | sync_c=False, | 661 | sync_c=False, |
662 | sync_s=False, | 662 | sync_s=False, |
663 | sync_tags=True, | ||
663 | clone_depth=None, | 664 | clone_depth=None, |
664 | upstream=None, | 665 | upstream=None, |
665 | parent=None, | 666 | parent=None, |
@@ -683,6 +684,7 @@ class Project(object): | |||
683 | groups: The `groups` attribute of manifest.xml's project element. | 684 | groups: The `groups` attribute of manifest.xml's project element. |
684 | sync_c: The `sync-c` attribute of manifest.xml's project element. | 685 | sync_c: The `sync-c` attribute of manifest.xml's project element. |
685 | sync_s: The `sync-s` attribute of manifest.xml's project element. | 686 | sync_s: The `sync-s` attribute of manifest.xml's project element. |
687 | sync_tags: The `sync-tags` attribute of manifest.xml's project element. | ||
686 | upstream: The `upstream` attribute of manifest.xml's project element. | 688 | upstream: The `upstream` attribute of manifest.xml's project element. |
687 | parent: The parent Project object. | 689 | parent: The parent Project object. |
688 | is_derived: False if the project was explicitly defined in the manifest; | 690 | is_derived: False if the project was explicitly defined in the manifest; |
@@ -715,6 +717,7 @@ class Project(object): | |||
715 | self.groups = groups | 717 | self.groups = groups |
716 | self.sync_c = sync_c | 718 | self.sync_c = sync_c |
717 | self.sync_s = sync_s | 719 | self.sync_s = sync_s |
720 | self.sync_tags = sync_tags | ||
718 | self.clone_depth = clone_depth | 721 | self.clone_depth = clone_depth |
719 | self.upstream = upstream | 722 | self.upstream = upstream |
720 | self.parent = parent | 723 | self.parent = parent |
@@ -1289,6 +1292,10 @@ class Project(object): | |||
1289 | elif self.manifest.default.sync_c: | 1292 | elif self.manifest.default.sync_c: |
1290 | current_branch_only = True | 1293 | current_branch_only = True |
1291 | 1294 | ||
1295 | if not no_tags: | ||
1296 | if not self.sync_tags: | ||
1297 | no_tags = True | ||
1298 | |||
1292 | if self.clone_depth: | 1299 | if self.clone_depth: |
1293 | depth = self.clone_depth | 1300 | depth = self.clone_depth |
1294 | else: | 1301 | else: |
@@ -1900,6 +1907,7 @@ class Project(object): | |||
1900 | groups=self.groups, | 1907 | groups=self.groups, |
1901 | sync_c=self.sync_c, | 1908 | sync_c=self.sync_c, |
1902 | sync_s=self.sync_s, | 1909 | sync_s=self.sync_s, |
1910 | sync_tags=self.sync_tags, | ||
1903 | parent=self, | 1911 | parent=self, |
1904 | is_derived=True) | 1912 | is_derived=True) |
1905 | result.append(subproject) | 1913 | result.append(subproject) |