diff options
author | Mike Frysinger <vapier@google.com> | 2020-12-04 05:32:06 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-12-04 17:27:11 +0000 |
commit | 51e39d536d9210dbae285f330a8ecb697d52aac6 (patch) | |
tree | 3aac0800cb93d2430195655db68937ab70939204 /manifest_xml.py | |
parent | 6342d5691478873708ee9363bd7dc8e275a75098 (diff) | |
download | git-repo-51e39d536d9210dbae285f330a8ecb697d52aac6.tar.gz |
manifest_xml: harmonize list fields
We allow project.groups to be whitespace or comma delimited, but
repo-hooks.enabled-list is only whitespace delimited. This hasn't
been a big deal as it's only ever had one valid value, but if we
want to add more, we should harmonize these a bit.
Refactor the groups method to be more generic, and run the enabled-
list attribute through it. Then add missing docs for it.
Change-Id: Iaa96a0faa9c4a68b313b49336751831b73bf855d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/290743
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index ad0017cc..00659316 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -292,8 +292,12 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
292 | if r.revision is not None: | 292 | if r.revision is not None: |
293 | e.setAttribute('revision', r.revision) | 293 | e.setAttribute('revision', r.revision) |
294 | 294 | ||
295 | def _ParseGroups(self, groups): | 295 | def _ParseList(self, field): |
296 | return [x for x in re.split(r'[,\s]+', groups) if x] | 296 | """Parse fields that contain flattened lists. |
297 | |||
298 | These are whitespace & comma separated. Empty elements will be discarded. | ||
299 | """ | ||
300 | return [x for x in re.split(r'[,\s]+', field) if x] | ||
297 | 301 | ||
298 | def ToXml(self, peg_rev=False, peg_rev_upstream=True, peg_rev_dest_branch=True, groups=None): | 302 | def ToXml(self, peg_rev=False, peg_rev_upstream=True, peg_rev_dest_branch=True, groups=None): |
299 | """Return the current manifest XML.""" | 303 | """Return the current manifest XML.""" |
@@ -302,7 +306,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
302 | if groups is None: | 306 | if groups is None: |
303 | groups = mp.config.GetString('manifest.groups') | 307 | groups = mp.config.GetString('manifest.groups') |
304 | if groups: | 308 | if groups: |
305 | groups = self._ParseGroups(groups) | 309 | groups = self._ParseList(groups) |
306 | 310 | ||
307 | doc = xml.dom.minidom.Document() | 311 | doc = xml.dom.minidom.Document() |
308 | root = doc.createElement('manifest') | 312 | root = doc.createElement('manifest') |
@@ -754,7 +758,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
754 | path = node.getAttribute('path') | 758 | path = node.getAttribute('path') |
755 | groups = node.getAttribute('groups') | 759 | groups = node.getAttribute('groups') |
756 | if groups: | 760 | if groups: |
757 | groups = self._ParseGroups(groups) | 761 | groups = self._ParseList(groups) |
758 | revision = node.getAttribute('revision') | 762 | revision = node.getAttribute('revision') |
759 | remote = node.getAttribute('remote') | 763 | remote = node.getAttribute('remote') |
760 | if remote: | 764 | if remote: |
@@ -776,7 +780,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
776 | if node.nodeName == 'repo-hooks': | 780 | if node.nodeName == 'repo-hooks': |
777 | # Get the name of the project and the (space-separated) list of enabled. | 781 | # Get the name of the project and the (space-separated) list of enabled. |
778 | repo_hooks_project = self._reqatt(node, 'in-project') | 782 | repo_hooks_project = self._reqatt(node, 'in-project') |
779 | enabled_repo_hooks = self._reqatt(node, 'enabled-list').split() | 783 | enabled_repo_hooks = self._ParseList(self._reqatt(node, 'enabled-list')) |
780 | 784 | ||
781 | # Only one project can be the hooks project | 785 | # Only one project can be the hooks project |
782 | if self._repo_hooks_project is not None: | 786 | if self._repo_hooks_project is not None: |
@@ -989,7 +993,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
989 | groups = '' | 993 | groups = '' |
990 | if node.hasAttribute('groups'): | 994 | if node.hasAttribute('groups'): |
991 | groups = node.getAttribute('groups') | 995 | groups = node.getAttribute('groups') |
992 | groups = self._ParseGroups(groups) | 996 | groups = self._ParseList(groups) |
993 | 997 | ||
994 | if parent is None: | 998 | if parent is None: |
995 | relpath, worktree, gitdir, objdir, use_git_worktrees = \ | 999 | relpath, worktree, gitdir, objdir, use_git_worktrees = \ |