[gerrit_util] Add fallback if missing Gerrit account

Bug: b/366261039
Change-Id: I7d22c4f03ad9bd837190dee7a511af3437a30434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5869050
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
This commit is contained in:
Allen Li
2024-09-18 21:57:33 +00:00
committed by LUCI CQ
parent 9650e09a4c
commit 4b94130034
4 changed files with 86 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ class ConfigChanger(object):
#
# Increment this when making changes to the config, so that reliant
# code can determine whether the config needs to be re-applied.
VERSION: int = 2
VERSION: int = 3
def __init__(
self,
@@ -130,6 +130,9 @@ class ConfigChanger(object):
email: str = scm.GIT.GetConfig(cwd, 'user.email') or ''
if gerrit_util.ShouldUseSSO(gerrit_host, email):
return ConfigMode.NEW_AUTH_SSO
if not gerrit_util.LuciAuthAuthenticator.gerrit_account_exists(
gerrit_host):
return ConfigMode.NO_AUTH
return ConfigMode.NEW_AUTH
def apply(self, cwd: str) -> None: