@ -2360,7 +2360,7 @@ class Changelist(object):
logging . debug (
logging . debug (
' Automatically configuring Git repo authentication (current version: %r , latest: %r ) ' ,
' Automatically configuring Git repo authentication (current version: %r , latest: %r ) ' ,
v , latestVer )
v , latestVer )
ConfigureGitRepoAuth ( )
ConfigureGitRepoAuth ( os . getcwd ( ) , Changelist ( ) )
scm . GIT . SetConfig ( settings . GetRoot ( ) ,
scm . GIT . SetConfig ( settings . GetRoot ( ) ,
' depot-tools.gitAuthAutoConfigured ' ,
' depot-tools.gitAuthAutoConfigured ' ,
str ( latestVer ) )
str ( latestVer ) )
@ -3663,7 +3663,7 @@ def DownloadGerritHook(force):
' chmod +x .git/hooks/commit-msg ' % src )
' chmod +x .git/hooks/commit-msg ' % src )
def ConfigureGitAuth ( ) - > None :
def ConfigureGitAuth ( cwd : str , cl : Changelist ) - > None :
""" Configure Git authentication.
""" Configure Git authentication.
This may modify the global Git config and the local repo config as
This may modify the global Git config and the local repo config as
@ -3672,7 +3672,6 @@ def ConfigureGitAuth() -> None:
logging . debug ( ' Configuring Git authentication... ' )
logging . debug ( ' Configuring Git authentication... ' )
logging . debug ( ' Configuring global Git authentication... ' )
logging . debug ( ' Configuring global Git authentication... ' )
cl = Changelist ( )
# We want the user's global config.
# We want the user's global config.
# We can probably assume the root directory doesn't have any local
# We can probably assume the root directory doesn't have any local
@ -3680,7 +3679,6 @@ def ConfigureGitAuth() -> None:
c = git_auth . ConfigChanger . new_from_env ( ' / ' , cl )
c = git_auth . ConfigChanger . new_from_env ( ' / ' , cl )
c . apply_global ( os . path . expanduser ( ' ~ ' ) )
c . apply_global ( os . path . expanduser ( ' ~ ' ) )
cwd = os . getcwd ( )
c2 = git_auth . ConfigChanger . new_from_env ( cwd , cl )
c2 = git_auth . ConfigChanger . new_from_env ( cwd , cl )
if c2 . mode == c . mode :
if c2 . mode == c . mode :
logging . debug (
logging . debug (
@ -3695,19 +3693,17 @@ def ConfigureGitAuth() -> None:
c2 . apply ( cwd )
c2 . apply ( cwd )
def ConfigureGitRepoAuth ( ) - > None :
def ConfigureGitRepoAuth ( cwd : str , cl : Changelist ) - > None :
""" Configure the current Git repo authentication. """
""" Configure the current Git repo authentication. """
logging . debug ( ' Configuring current Git repo authentication... ' )
logging . debug ( ' Configuring current Git repo authentication... ' )
cwd = os . getcwd ( )
c = git_auth . ConfigChanger . new_from_env ( cwd , cl )
c = git_auth . ConfigChanger . new_from_env ( cwd , Changelist ( ) )
c . apply ( cwd )
c . apply ( cwd )
def ClearGitRepoAuth ( ) - > None :
def ClearGitRepoAuth ( cwd : str , cl : Changelist ) - > None :
""" Clear the current Git repo authentication. """
""" Clear the current Git repo authentication. """
logging . debug ( ' Clearing current Git repo authentication... ' )
logging . debug ( ' Clearing current Git repo authentication... ' )
cwd = os . getcwd ( )
c = git_auth . ConfigChanger . new_from_env ( cwd , cl )
c = git_auth . ConfigChanger . new_from_env ( cwd , Changelist ( ) )
c . mode = git_auth . ConfigMode . NO_AUTH
c . mode = git_auth . ConfigMode . NO_AUTH
c . apply ( cwd )
c . apply ( cwd )
@ -3941,10 +3937,10 @@ def CMDcreds_check(parser, args):
_ , _ = parser . parse_args ( args )
_ , _ = parser . parse_args ( args )
if newauth . Enabled ( ) :
if newauth . Enabled ( ) :
ConfigureGitAuth ( )
ConfigureGitAuth ( os . getcwd ( ) , Changelist ( ) )
return 0
return 0
if newauth . ExplicitlyDisabled ( ) :
if newauth . ExplicitlyDisabled ( ) :
ClearGitRepoAuth ( )
ClearGitRepoAuth ( os . getcwd ( ) , Changelist ( ) )
# Code below checks .gitcookies. Abort if using something else.
# Code below checks .gitcookies. Abort if using something else.
auth_name , _ = gerrit_util . debug_auth ( )
auth_name , _ = gerrit_util . debug_auth ( )