mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
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>
This commit is contained in:
committed by
Chirayu Desai
parent
275e4b727a
commit
a8864fba9f
11
command.py
11
command.py
@ -186,6 +186,17 @@ class Command(object):
|
||||
result.sort(key=_getpath)
|
||||
return result
|
||||
|
||||
def FindProjects(self, args):
|
||||
result = []
|
||||
for project in self.GetProjects(''):
|
||||
for arg in args:
|
||||
pattern = re.compile(r'%s' % arg, re.IGNORECASE)
|
||||
if pattern.search(project.name) or pattern.search(project.relpath):
|
||||
result.append(project)
|
||||
break
|
||||
result.sort(key=lambda project: project.relpath)
|
||||
return result
|
||||
|
||||
# pylint: disable=W0223
|
||||
# Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not
|
||||
# override method `Execute` which is abstract in `Command`. Since that method
|
||||
|
Reference in New Issue
Block a user