$ git cl creds-check
+$ git cl creds-check --global
diff --git a/git_auth.py b/git_auth.py index 3a916337a..542542a84 100644 --- a/git_auth.py +++ b/git_auth.py @@ -463,11 +463,11 @@ class ConfigWizard(object): self._ui = ui self._user_actions = [] - def run(self, remote_url: str): + def run(self, *, remote_url: str, force_global: bool): with self._handle_config_errors(): - self._run(remote_url) + self._run(remote_url=remote_url, force_global=force_global) - def _run(self, remote_url: str): + def _run(self, *, remote_url: str, force_global: bool): self._println('This tool will help check your Gerrit authentication.') self._println( '(Report any issues to https://issues.chromium.org/issues/new?component=1456702&template=2076315)' @@ -481,12 +481,21 @@ class ConfigWizard(object): self._set_config('protocol.sso.allow', 'always', scope='global') self._println() if _is_gerrit_url(remote_url): - self._println( - 'Looks like we are running inside a Gerrit repository,') - self._println( - f'so we will check your Git configuration for {remote_url}') - parts = urllib.parse.urlsplit(remote_url) - self._run_inside_repo(parts) + if force_global: + self._println( + 'We will pretend to be running outside of a Gerrit repository' + ) + self._println( + 'and check your global Git configuration since you passed --global.' + ) + self._run_outside_repo() + else: + self._println( + 'Looks like we are running inside a Gerrit repository,') + self._println( + f'so we will check your Git configuration for {remote_url}') + parts = urllib.parse.urlsplit(remote_url) + self._run_inside_repo(parts) else: self._println( 'Looks like we are running outside of a Gerrit repository,') @@ -703,6 +712,7 @@ class ConfigWizard(object): if email: self._println(f'Your global Git email is: {email}') return email + self._println() self._println( 'You do not have an email configured in your global Git config.') if not self._read_yn('Do you want to set one now?', default=True): diff --git a/git_cl.py b/git_cl.py index 006f0360d..e7718b004 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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()) diff --git a/man/html/depot_tools_tutorial.html b/man/html/depot_tools_tutorial.html index 3cad3baed..7ea45244e 100644 --- a/man/html/depot_tools_tutorial.html +++ b/man/html/depot_tools_tutorial.html @@ -1004,10 +1004,10 @@ commands:
Unless you plan on only fetching code anonymously, you’ll need to set -up your auth config in Git. Run this in your home directory:
$ git cl creds-check
+$ git cl creds-check --global
Pick an empty directory and run one of the following: