RejectExisting removes any credentials cached for the given hostname by the configured git credential helper.
(hostname string)
| 15 | |
| 16 | // RejectExisting removes any credentials cached for the given hostname by the configured git credential helper. |
| 17 | func (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. |