From 0b96058844728db8040a7348cc4c61fde453401a Mon Sep 17 00:00:00 2001 From: Orr Bernstein Date: Thu, 22 Dec 2022 20:16:18 +0000 Subject: [PATCH] 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 Reviewed-by: Joanna Wang --- git_cl.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/git_cl.py b/git_cl.py index 9708895b9..869ea230e 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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.