diff options
author | Zhiguang Li <muzili@gmail.com> | 2013-03-15 10:32:10 +0800 |
---|---|---|
committer | Chirayu Desai <cdesai@cyanogenmod.org> | 2013-04-29 16:19:26 +0530 |
commit | a8864fba9fd21f412cd0e2c6e072deeb204049bb (patch) | |
tree | 70008b8438542ff08fc9c5883e1b35f15c12b1c8 /subcmds/forall.py | |
parent | 275e4b727a68cbf32c686d80736772c843771d98 (diff) | |
download | git-repo-a8864fba9fd21f412cd0e2c6e072deeb204049bb.tar.gz |
Add regex support for subcommand forall
Filter the project list based on regex or wildcard matching
of strings, then we can handle subset of all projects.
Change-Id: Ib6c23aec79e7d981f7b6a5eb0ae93c44effec467
Signed-off-by: Zhiguang Li <muzili@gmail.com>
Diffstat (limited to 'subcmds/forall.py')
-rw-r--r-- | subcmds/forall.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 4c1c9ff8..7d5f7794 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -42,10 +42,14 @@ class Forall(Command, MirrorSafeCommand): | |||
42 | helpSummary = "Run a shell command in each project" | 42 | helpSummary = "Run a shell command in each project" |
43 | helpUsage = """ | 43 | helpUsage = """ |
44 | %prog [<project>...] -c <command> [<arg>...] | 44 | %prog [<project>...] -c <command> [<arg>...] |
45 | %prog -r str1 [str2] ... -c <command> [<arg>...]" | ||
45 | """ | 46 | """ |
46 | helpDescription = """ | 47 | helpDescription = """ |
47 | Executes the same shell command in each project. | 48 | Executes the same shell command in each project. |
48 | 49 | ||
50 | The -r option allows running the command only on projects matching | ||
51 | regex or wildcard expression. | ||
52 | |||
49 | Output Formatting | 53 | Output Formatting |
50 | ----------------- | 54 | ----------------- |
51 | 55 | ||
@@ -103,6 +107,9 @@ without iterating through the remaining projects. | |||
103 | setattr(parser.values, option.dest, list(parser.rargs)) | 107 | setattr(parser.values, option.dest, list(parser.rargs)) |
104 | while parser.rargs: | 108 | while parser.rargs: |
105 | del parser.rargs[0] | 109 | del parser.rargs[0] |
110 | p.add_option('-r', '--regex', | ||
111 | dest='regex', action='store_true', | ||
112 | help="Execute the command only on projects matching regex or wildcard expression") | ||
106 | p.add_option('-c', '--command', | 113 | p.add_option('-c', '--command', |
107 | help='Command (and arguments) to execute', | 114 | help='Command (and arguments) to execute', |
108 | dest='command', | 115 | dest='command', |
@@ -166,7 +173,12 @@ without iterating through the remaining projects. | |||
166 | rc = 0 | 173 | rc = 0 |
167 | first = True | 174 | first = True |
168 | 175 | ||
169 | for project in self.GetProjects(args): | 176 | if not opt.regex: |
177 | projects = self.GetProjects(args) | ||
178 | else: | ||
179 | projects = self.FindProjects(args) | ||
180 | |||
181 | for project in projects: | ||
170 | env = os.environ.copy() | 182 | env = os.environ.copy() |
171 | def setenv(name, val): | 183 | def setenv(name, val): |
172 | if val is None: | 184 | if val is None: |