From 818d4ba5b843ce448158e9c755cb2c43ecbcf8cc Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 16 May 2024 13:11:58 +0200 Subject: [PATCH] Remove unnecessary credential setup private method --- pkg/cmd/auth/shared/git_credential.go | 6 +----- pkg/cmd/auth/shared/git_credential_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) 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) } }