[git_cl] Adding OLD_AUTH config mode

Can be used to remove config changes.  Not called yet.

There's some logic duplication, will try to clean up later.

Bug: b/351024645
Change-Id: Ibdda4b93e600efc4b84240374e58478e2cc1501a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5693419
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
changes/19/5693419/5
Allen Li 1 year ago committed by LUCI CQ
parent 57000ea275
commit c3b1e5e58b

@ -3678,6 +3678,7 @@ class GitConfigMode(enum.Enum):
"""Modes to pass to GitAuthConfigChanger"""
NEW_AUTH = 1
NEW_AUTH_SSO = 2
OLD_AUTH = 3
class GitAuthConfigChanger(object):
@ -3746,6 +3747,8 @@ class GitAuthConfigChanger(object):
scm.GIT.SetConfig(self._cwd, cred_key, 'luci', append=True)
elif self._mode == GitConfigMode.NEW_AUTH_SSO:
scm.GIT.SetConfig(self._cwd, cred_key, None, modify_all=True)
elif self._mode == GitConfigMode.OLD_AUTH:
scm.GIT.SetConfig(self._cwd, cred_key, None, modify_all=True)
else:
raise TypeError(f'Invalid mode {self._mode!r}')
@ -3758,6 +3761,9 @@ class GitAuthConfigChanger(object):
elif self._mode == GitConfigMode.NEW_AUTH_SSO:
scm.GIT.SetConfig(self._cwd, 'protocol.sso.allow', 'always')
scm.GIT.SetConfig(self._cwd, sso_key, base_url, modify_all=True)
elif self._mode == GitConfigMode.OLD_AUTH:
scm.GIT.SetConfig(self._cwd, 'protocol.sso.allow', None)
scm.GIT.SetConfig(self._cwd, sso_key, None, modify_all=True)
else:
raise TypeError(f'Invalid mode {self._mode!r}')
@ -3769,6 +3775,11 @@ class GitAuthConfigChanger(object):
elif self._mode == GitConfigMode.NEW_AUTH_SSO:
# Override potential global gitcookie config
scm.GIT.SetConfig(self._cwd, 'http.gitcookies', '', modify_all=True)
elif self._mode == GitConfigMode.OLD_AUTH:
scm.GIT.SetConfig(self._cwd,
'http.gitcookies',
None,
modify_all=True)
else:
raise TypeError(f'Invalid mode {self._mode!r}')

Loading…
Cancel
Save