Remove unnecessary credential setup private method

This commit is contained in:
William Martin 2024-05-16 13:11:58 +02:00
parent c16836bcf7
commit 818d4ba5b8
2 changed files with 9 additions and 13 deletions

View file

@ -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)
}

View file

@ -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)
}
}