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)
| 474 | // is not set, it returns "simple" (the default git value). See |
| 475 | // https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault |
| 476 | func (c *Client) PushDefault(ctx context.Context) (PushDefault, error) { |
| 477 | pushDefault, err := c.Config(ctx, "push.default") |
| 478 | if err == nil { |
| 479 | return ParsePushDefault(pushDefault) |
| 480 | } |
| 481 | |
| 482 | // If there is an error that the config key is not set, return the default value |
| 483 | // that git uses since 2.0. |
| 484 | var gitError *GitError |
| 485 | if ok := errors.As(err, &gitError); ok && gitError.ExitCode == 1 { |
| 486 | return PushDefaultSimple, nil |
| 487 | } |
| 488 | return "", err |
| 489 | } |
| 490 | |
| 491 | // RemotePushDefault returns the value of remote.pushDefault in the config. If |
| 492 | // the value is not set, it returns an empty string. |