diff options
author | Graham Christensen <graham@grahamc.com> | 2015-07-29 17:02:54 -0500 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2015-07-30 12:59:35 -0500 |
commit | 0369a069ade1602879c16dd33dc592bed3f17c0f (patch) | |
tree | 96d4f4970bc5d0b3ba7fcdca5946e47e170ff2bc | |
parent | abaa7f312f1b6c8d11d7c757fe909900ce5788b5 (diff) | |
download | git-repo-0369a069ade1602879c16dd33dc592bed3f17c0f.tar.gz |
Support filtering by group on forall and list subcmd
Enable operating against groups of repositories. As it stands, it isn't
compatible with `-r/--regex`.
`repo forall -g groupname -c pwd` will run `pwd` for all projects in
groupname.
`repo forall -g thisgroup,-butnotthisone -c pwd` will run `pwd` for all
projects in `thisgroup` but not `butnotthisone`.
`repo list -g groupname -n` will list all the names of repos in
`groupname`.
Change-Id: Ia75c50ce52541d1c8cea2874b20a4db2e0e54960
-rw-r--r-- | command.py | 5 | ||||
-rw-r--r-- | subcmds/forall.py | 5 | ||||
-rw-r--r-- | subcmds/list.py | 5 |
3 files changed, 11 insertions, 4 deletions
@@ -126,7 +126,7 @@ class Command(object): | |||
126 | pass | 126 | pass |
127 | return project | 127 | return project |
128 | 128 | ||
129 | def GetProjects(self, args, missing_ok=False, submodules_ok=False): | 129 | def GetProjects(self, args, groups='', missing_ok=False, submodules_ok=False): |
130 | """A list of projects that match the arguments. | 130 | """A list of projects that match the arguments. |
131 | """ | 131 | """ |
132 | all_projects_list = self.manifest.projects | 132 | all_projects_list = self.manifest.projects |
@@ -134,7 +134,8 @@ class Command(object): | |||
134 | 134 | ||
135 | mp = self.manifest.manifestProject | 135 | mp = self.manifest.manifestProject |
136 | 136 | ||
137 | groups = mp.config.GetString('manifest.groups') | 137 | if not groups: |
138 | groups = mp.config.GetString('manifest.groups') | ||
138 | if not groups: | 139 | if not groups: |
139 | groups = 'default,platform-' + platform.system().lower() | 140 | groups = 'default,platform-' + platform.system().lower() |
140 | groups = [x for x in re.split(r'[,\s]+', groups) if x] | 141 | groups = [x for x in re.split(r'[,\s]+', groups) if x] |
diff --git a/subcmds/forall.py b/subcmds/forall.py index b93cd6d0..96dc99d1 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -120,6 +120,9 @@ without iterating through the remaining projects. | |||
120 | p.add_option('-r', '--regex', | 120 | p.add_option('-r', '--regex', |
121 | dest='regex', action='store_true', | 121 | dest='regex', action='store_true', |
122 | help="Execute the command only on projects matching regex or wildcard expression") | 122 | help="Execute the command only on projects matching regex or wildcard expression") |
123 | p.add_option('-g', '--groups', | ||
124 | dest='groups', | ||
125 | help="Execute the command only on projects matching the specified groups") | ||
123 | p.add_option('-c', '--command', | 126 | p.add_option('-c', '--command', |
124 | help='Command (and arguments) to execute', | 127 | help='Command (and arguments) to execute', |
125 | dest='command', | 128 | dest='command', |
@@ -213,7 +216,7 @@ without iterating through the remaining projects. | |||
213 | self.manifest.Override(smart_sync_manifest_path) | 216 | self.manifest.Override(smart_sync_manifest_path) |
214 | 217 | ||
215 | if not opt.regex: | 218 | if not opt.regex: |
216 | projects = self.GetProjects(args) | 219 | projects = self.GetProjects(args, groups=opt.groups) |
217 | else: | 220 | else: |
218 | projects = self.FindProjects(args) | 221 | projects = self.FindProjects(args) |
219 | 222 | ||
diff --git a/subcmds/list.py b/subcmds/list.py index 945c28d8..ca51c5f7 100644 --- a/subcmds/list.py +++ b/subcmds/list.py | |||
@@ -35,6 +35,9 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
35 | p.add_option('-r', '--regex', | 35 | p.add_option('-r', '--regex', |
36 | dest='regex', action='store_true', | 36 | dest='regex', action='store_true', |
37 | help="Filter the project list based on regex or wildcard matching of strings") | 37 | help="Filter the project list based on regex or wildcard matching of strings") |
38 | p.add_option('-g', '--groups', | ||
39 | dest='groups', | ||
40 | help="Filter the project list based on the groups the project is in") | ||
38 | p.add_option('-f', '--fullpath', | 41 | p.add_option('-f', '--fullpath', |
39 | dest='fullpath', action='store_true', | 42 | dest='fullpath', action='store_true', |
40 | help="Display the full work tree path instead of the relative path") | 43 | help="Display the full work tree path instead of the relative path") |
@@ -62,7 +65,7 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
62 | sys.exit(1) | 65 | sys.exit(1) |
63 | 66 | ||
64 | if not opt.regex: | 67 | if not opt.regex: |
65 | projects = self.GetProjects(args) | 68 | projects = self.GetProjects(args, groups=opt.groups) |
66 | else: | 69 | else: |
67 | projects = self.FindProjects(args) | 70 | projects = self.FindProjects(args) |
68 | 71 | ||