PushDefault returns the value of push.default in the config. If the value is not set, it returns "simple" (the default git value). See https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault
(ctx context.Context)
| 536 | // is not set, it returns "simple" (the default git value). See |
| 537 | // https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault |
| 538 | func (c *Client) PushDefault(ctx context.Context) (PushDefault, error) { |
| 539 | pushDefault, err := c.Config(ctx, "push.default") |
| 540 | if err == nil { |
| 541 | return ParsePushDefault(pushDefault) |
| 542 | } |
| 543 | |
| 544 | // If there is an error that the config key is not set, return the default value |
| 545 | // that git uses since 2.0. |
| 546 | var gitError *GitError |
| 547 | if ok := errors.As(err, &gitError); ok && gitError.ExitCode == 1 { |
| 548 | return PushDefaultSimple, nil |
| 549 | } |
| 550 | return "", err |
| 551 | } |
| 552 | |
| 553 | // RemotePushDefault returns the value of remote.pushDefault in the config. If |
| 554 | // the value is not set, it returns an empty string. |