Improve printed info in git cl creds-check

May help user to diagnose/debug some issues.

Bug: b/372552465
Change-Id: Ia9fc4fd49c8ee80bccd98442ed5589324d0b23b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6068966
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Allen Li <ayatane@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
changes/66/6068966/5
Allen Li 8 months ago committed by LUCI CQ
parent 98d0d6ec12
commit d2fdba4e78

@ -3888,17 +3888,23 @@ def CMDcreds_check(parser, args):
if newauth.Enabled():
cl = Changelist()
host = cl.GetGerritHost()
print(f'Using Gerrit host: {host!r}')
git_auth.Configure(os.getcwd(), cl)
# Perform some advisory checks
email = scm.GIT.GetConfig(os.getcwd(), 'user.email') or ''
if not gerrit_util.ShouldUseSSO(cl.GetGerritHost(), email):
print(f'Using email (configured in Git): {email!r}')
if gerrit_util.ShouldUseSSO(host, email):
print('Detected that we should be using SSO.')
else:
print('Detected that we should be using luci-auth.')
a = gerrit_util.LuciAuthAuthenticator()
try:
a.luci_auth.get_access_token()
except auth.LoginRequiredError as e:
print('NOTE: You are not logged in with luci-auth.')
print(
'You may not be able to perform some actions without logging in.'
'You will not be able to perform many actions without logging in.'
)
print('If you wish to log in, run:')
print(' ' + e.login_command)

Loading…
Cancel
Save