MCPcopy Create free account
hub / github.com/cli/cli / RejectExisting

Method RejectExisting

pkg/cmd/auth/shared/gitcredentials/updater.go:17–32  ·  view source on GitHub ↗

RejectExisting removes any credentials cached for the given hostname by the configured git credential helper.

(hostname string)

Source from the content-addressed store, hash-verified

15
16// RejectExisting removes any credentials cached for the given hostname by the configured git credential helper.
17func (u *Updater) RejectExisting(hostname string) error {
18 ctx := context.TODO()
19
20 rejectCmd, err := u.GitClient.Command(ctx, "credential", "reject")
21 if err != nil {
22 return err
23 }
24
25 rejectCmd.Stdin = bytes.NewBufferString(heredoc.Docf(`
26 protocol=https
27 host=%s
28 `, hostname))
29
30 _, err = rejectCmd.Output()
31 return err
32}
33
34// Update updates the git credentials for a given hostname, first by rejecting any existing credentials and then
35// approving the new credentials.

Callers 3

TestRejectExistingFunction · 0.95
UpdateMethod · 0.95
SetupMethod · 0.80

Calls 2

CommandMethod · 0.80
OutputMethod · 0.65

Tested by 1

TestRejectExistingFunction · 0.76