[git_cl] Extract helper methods

Change-Id: I6fd49699a7046d7f689ef59bf35d3d2a62c7438d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5689681
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
changes/81/5689681/3
Allen Li 11 months ago committed by LUCI CQ
parent 443bc06b19
commit 902a9de39e

@ -3694,9 +3694,16 @@ class GitAuthConfigChanger(object):
def apply(self):
"""Apply config changes."""
logging.debug('Configuring current Git repo authentication...')
cwd: str = os.getcwd()
# Credential helper
self._apply_cred_helper()
self._apply_sso()
# Override potential global gitcookie config
scm.GIT.SetConfig(cwd, 'http.gitcookies', '', modify_all=True)
def _apply_cred_helper(self):
"""Apply config changes relating to credential helper."""
cwd: str = os.getcwd()
if self._should_use_sso:
scm.GIT.SetConfig(cwd,
f'credential.{self._base_url}.helper',
@ -3712,6 +3719,9 @@ class GitAuthConfigChanger(object):
'luci',
append=True)
def _apply_sso(self):
"""Apply config changes relating to SSO."""
cwd: str = os.getcwd()
# SSO
if self._should_use_sso:
scm.GIT.SetConfig(cwd, 'protocol.sso.allow', 'always')
@ -3726,9 +3736,6 @@ class GitAuthConfigChanger(object):
None,
modify_all=True)
# Override potential global gitcookie config
scm.GIT.SetConfig(cwd, 'http.gitcookies', '', modify_all=True)
class _GitCookiesChecker(object):
"""Provides facilities for validating and suggesting fixes to .gitcookies."""

Loading…
Cancel
Save