Documentation
¶
Overview ¶
Package git implements helpers for interacting with git
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoHeadBranch is returned when a repository's HEAD (aka default) branch cannot // be determine. ErrNoHeadBranch = errors.New("failed to find a head branch, does one exist?") // ErrNoRemoteHeadBranch is returned when a repository's remote default/HEAD branch // cannot be determined. ErrNoRemoteHeadBranch = errors.New("failed to get head branch from remote origin") // ErrNoOriginRemote is returned when a repository has no "origin" remote and its // default branch cannot be inferred from its local branches. ErrNoOriginRemote = errors.New(`the repository has no "origin" remote to determine the default branch from`) )
This block contains errors and regexes.
Functions ¶
func GetDefaultBranch ¶
GetDefaultBranch determines the default/HEAD branch for a given git repository. It asks the "origin" remote. A repository without an "origin" remote, such as one that was just created, has no remote to ask, so its default branch is inferred from its local branches instead, see inferLocalDefaultBranch.
func GetDefaultBranchWithRetry ¶
func GetDefaultBranchWithRetry(ctx context.Context, path string, opts ...retry.Option) (string, error)
GetDefaultBranchWithRetry is GetDefaultBranch, retried with backoff (3 attempts by default) because it asks the remote, which can fail transiently. It does not retry when asking again won't change the answer: there is no "origin" remote and the branch can't be inferred, or git ran fine but did not report a branch. opts are applied after the defaults.
Types ¶
This section is empty.