[git_cl] Add --global to creds-check

The UX of cd'ing to a non-Gerrit repo to setup common repo auth is not
good.  Also people don't read.

Bug: 408501013
Change-Id: Ia31914cf8672d0b5a6033de11c928140fd34a95c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6442235
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
This commit is contained in:
Allen Li
2025-04-08 15:16:09 -07:00
committed by LUCI CQ
parent 07d24776f2
commit f5b53c0e98
5 changed files with 37 additions and 22 deletions

View File

@@ -3900,7 +3900,12 @@ class _GitCookiesChecker(object):
@metrics.collector.collect_metrics('git cl creds-check')
def CMDcreds_check(parser, args):
"""Checks credentials and suggests changes."""
_, _ = parser.parse_args(args)
parser.add_option(
'--global',
action='store_true',
dest='force_global',
help='Check global credentials instead of for the current repo.')
options, args = parser.parse_args(args)
if newauth.SwitchedOn():
cl = Changelist()
@@ -3910,7 +3915,7 @@ def CMDcreds_check(parser, args):
remote_url = ''
wizard = git_auth.ConfigWizard(
git_auth.UserInterface(sys.stdin, sys.stdout))
wizard.run(remote_url)
wizard.run(remote_url=remote_url, force_global=options.force_global)
return 0
if newauth.ExplicitlyDisabled():
git_auth.ClearRepoConfig(os.getcwd(), Changelist())