Handle erase operation in auth git-credential command (#6805)

This commit is contained in:
Sam Coe 2023-01-03 14:03:27 -08:00 committed by GitHub
parent 08d7ea5f62
commit 47b27cde4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -54,7 +54,12 @@ func NewCmdCredential(f *cmdutil.Factory, runF func(*CredentialOptions) error) *
func helperRun(opts *CredentialOptions) error {
if opts.Operation == "store" {
// We pretend to implement the "store" operation, but do nothing since we already have a cached token.
return cmdutil.SilentError
return nil
}
if opts.Operation == "erase" {
// We pretend to implement the "erase" operation, but do nothing since we don't want git to cause user to be logged out.
return nil
}
if opts.Operation != "get" {

View file

@ -218,6 +218,25 @@ func Test_helperRun(t *testing.T) {
`),
wantStderr: "",
},
{
name: "noop store operation",
opts: CredentialOptions{
Operation: "store",
},
},
{
name: "noop erase operation",
opts: CredentialOptions{
Operation: "erase",
},
},
{
name: "unknown operation",
opts: CredentialOptions{
Operation: "unknown",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {