abandon_stale.py: Optionally exclude WIP changes

Including the "-is:wip" term by default causes the script to fail
when run against Gerrit server earlier than 2.15.

Add a new --exclude-wip option to optionally add "-is:wip".

Change-Id: Ia26ce274d9250a076fa9072af2b8260c7a8087f5
This commit is contained in:
David Pursehouse
2018-08-30 13:45:31 +09:00
parent dcd4763a3b
commit d69ad71df4

View File

@@ -103,6 +103,9 @@ def _main():
default=None,
action='store',
help='only abandon changes owned by the given user')
parser.add_option('--exclude-wip', dest='exclude_wip',
action='store_true',
help='Exclude changes that are Work-in-Progress')
parser.add_option('-v', '--verbose', dest='verbose',
action='store_true',
help='enable verbose (debug) logging')
@@ -148,7 +151,9 @@ def _main():
if options.testmode:
query_terms = ["status:new", "owner:self", "topic:test-abandon"]
else:
query_terms = ["status:new", "-is:wip", "age:%s" % options.age]
query_terms = ["status:new", "age:%s" % options.age]
if options.exclude_wip:
query_terms += ["-is:wip"]
if options.branches:
query_terms += ["branch:%s" % b for b in options.branches]
elif options.exclude_branches: