gerrit: allow filtering by branch
It is at times handy to be able to filter gerrit output by branch.
Adding a new command line option to allow user to specify a branch
when necessary.
BUG=none
TEST=ran the command with and without the new command line argument:
$ gerrit -b firmware-storm-6315.B mine | wc -l
146
$ gerrit mine | wc -l
171
. verified that the list of CLs reported with the -b option indeed
belongs to the requested branch
Change-Id: I7c0ef83bc007d661fe65e9abcf50dee5b77b7576
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/237892
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index 1a35f74..2b70fba 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -166,6 +166,9 @@
"""Query gerrit and filter/clean up the results"""
ret = []
+ if opts.branch is not None:
+ query += ' branch:%s' % opts.branch
+
helper, _ = GetGerrit(opts)
for cl in helper.Query(query, raw=True, bypass_cache=False):
# Gerrit likes to return a stats record too.
@@ -401,6 +404,8 @@
help='Show what would be done, but do not make changes')
parser.add_argument('-v', '--verbose', default=False, action='store_true',
help='Be more verbose in output')
+ parser.add_argument('-b', '--branch',
+ help='Limit output to the specific branch')
parser.add_argument('args', nargs='+')
opts = parser.parse_args(argv)