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

Method PushDefault

git/client.go:539–552  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

TestClientPushDefaultFunction · 0.95

Calls 2

ConfigMethod · 0.95
ParsePushDefaultFunction · 0.85

Tested by 1

TestClientPushDefaultFunction · 0.76