Make git cl issue handle bad arguments more gracefully.

Running "git cl issue -r invalid_input" will now produce an error
message and continue, instead of crashing with a stacktrace.

Change-Id: I17626a513df904a1a3ff725ec7a17e8541db6bf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1538978
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
changes/78/1538978/3
Lei Zhang 6 years ago committed by Commit Bot
parent fef79d40ae
commit 5a368d4dd9

@ -4142,11 +4142,14 @@ def CMDissue(parser, args):
args = sorted(issue_branch_map.iterkeys())
result = {}
for issue in args:
if not issue:
try:
issue_num = int(issue)
except ValueError:
print('ERROR cannot parse issue number: %s' % issue, file=sys.stderr)
continue
result[int(issue)] = issue_branch_map.get(int(issue))
result[issue_num] = issue_branch_map.get(issue_num)
print('Branch for issue number %s: %s' % (
issue, ', '.join(issue_branch_map.get(int(issue)) or ('None',))))
issue, ', '.join(issue_branch_map.get(issue_num) or ('None',))))
if options.json:
write_json(options.json, result)
return 0

Loading…
Cancel
Save