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