diff --git a/pkg/cmd/auth/shared/git_credential.go b/pkg/cmd/auth/shared/git_credential.go index 7ddd9aeae..d21c60dfc 100644 --- a/pkg/cmd/auth/shared/git_credential.go +++ b/pkg/cmd/auth/shared/git_credential.go @@ -53,10 +53,6 @@ func (flow *GitCredentialFlow) ShouldSetup() bool { } func (flow *GitCredentialFlow) Setup(hostname, username, authToken string) error { - return flow.gitCredentialSetup(hostname, username, authToken) -} - -func (flow *GitCredentialFlow) gitCredentialSetup(hostname, username, password string) error { // If there is no credential helper configured then we will set ourselves up as // the credential helper for this host. if !flow.helper.IsConfigured() { @@ -64,5 +60,5 @@ func (flow *GitCredentialFlow) gitCredentialSetup(hostname, username, password s } // Otherwise, we'll tell git to inform the existing credential helper of the new credentials. - return flow.Updater.Update(hostname, username, password) + return flow.Updater.Update(hostname, username, authToken) } diff --git a/pkg/cmd/auth/shared/git_credential_test.go b/pkg/cmd/auth/shared/git_credential_test.go index 211e8da99..19ab9b752 100644 --- a/pkg/cmd/auth/shared/git_credential_test.go +++ b/pkg/cmd/auth/shared/git_credential_test.go @@ -8,7 +8,7 @@ import ( "github.com/cli/cli/v2/pkg/cmd/auth/shared/gitcredentials" ) -func TestGitCredentialSetup_configureExisting(t *testing.T) { +func TestSetup_configureExisting(t *testing.T) { cs, restoreRun := run.Stub() defer restoreRun(t) cs.Register(`git credential reject`, 0, "") @@ -21,8 +21,8 @@ func TestGitCredentialSetup_configureExisting(t *testing.T) { }, } - if err := f.gitCredentialSetup("example.com", "monalisa", "PASSWD"); err != nil { - t.Errorf("GitCredentialSetup() error = %v", err) + if err := f.Setup("example.com", "monalisa", "PASSWD"); err != nil { + t.Errorf("Setup() error = %v", err) } } @@ -70,13 +70,13 @@ func TestGitCredentialsSetup_setOurs_GH(t *testing.T) { }, } - if err := f.gitCredentialSetup("github.com", "monalisa", "PASSWD"); err != nil { - t.Errorf("GitCredentialSetup() error = %v", err) + if err := f.Setup("github.com", "monalisa", "PASSWD"); err != nil { + t.Errorf("Setup() error = %v", err) } } -func TestGitCredentialSetup_setOurs_nonGH(t *testing.T) { +func TestSetup_setOurs_nonGH(t *testing.T) { cs, restoreRun := run.Stub() defer restoreRun(t) cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) { @@ -104,7 +104,7 @@ func TestGitCredentialSetup_setOurs_nonGH(t *testing.T) { }, } - if err := f.gitCredentialSetup("example.com", "monalisa", "PASSWD"); err != nil { - t.Errorf("GitCredentialSetup() error = %v", err) + if err := f.Setup("example.com", "monalisa", "PASSWD"); err != nil { + t.Errorf("Setup() error = %v", err) } }