Add an option to 'git cl web' to print the issue URL instead of opening it.

This new option (-n,--no-browser) prints the issue URL instead of opening it in
the browser. This is helpful, for instance, if you're SSH'ed in from a
Chromebook.

Change-Id: I28793280901f054af4eed2dbf2ce1fd109b8d37b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4121245
Commit-Queue: Orr Bernstein <orrb@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
changes/45/4121245/3
Orr Bernstein 2 years ago committed by LUCI CQ
parent cf31045b34
commit 0b96058844

@ -5025,7 +5025,13 @@ def CMDupstream(parser, args):
@metrics.collector.collect_metrics('git cl web')
def CMDweb(parser, args):
"""Opens the current CL in the web browser."""
_, args = parser.parse_args(args)
parser.add_option('-p',
'--print-only',
action='store_true',
dest='print_only',
help='Only print the Gerrit URL, don\'t open it in the '
'browser.')
(options, args) = parser.parse_args(args)
if args:
parser.error('Unrecognized args: %s' % ' '.join(args))
@ -5034,6 +5040,10 @@ def CMDweb(parser, args):
print('ERROR No issue to open', file=sys.stderr)
return 1
if options.print_only:
print(issue_url)
return 0
# Redirect I/O before invoking browser to hide its output. For example, this
# allows us to hide the "Created new window in existing browser session."
# message from Chrome. Based on https://stackoverflow.com/a/2323563.

Loading…
Cancel
Save