Documentation
¶
Overview ¶
Package facts exposes git repository facts (current branch, origin remote, owner) and a forward-only check, all through an injected Runner so the logic is testable without invoking the real git binary.
Index ¶
Constants ¶
const ( // ErrDetachedHead is returned when HEAD is not on a branch (a branch tip is required). ErrDetachedHead errs.Const = "git: HEAD is detached; not on a branch tip" // ErrNoOrigin is returned when remote.origin.url is not configured. ErrNoOrigin errs.Const = "git: no origin remote configured" )
Variables ¶
This section is empty.
Functions ¶
func EnsureForwardOnly ¶
EnsureForwardOnly verifies the working tree satisfies the forward-only invariant: HEAD is on a branch tip rather than a detached commit.
Types ¶
type BranchName ¶
type BranchName string
BranchName is a git branch name.
func Branch ¶
func Branch(r Runner) (BranchName, error)
Branch returns the current branch name, or ErrDetachedHead when HEAD is detached.
type ExecRunner ¶
type ExecRunner struct{}
ExecRunner is a Runner backed by the real git binary.
func NewExecRunner ¶
func NewExecRunner() ExecRunner
NewExecRunner returns a Runner that invokes git.
func (ExecRunner) Run ¶
func (ExecRunner) Run(args ...Arg) (CommandOutput, error)
Run invokes git with the given arguments and returns its standard output.
type Runner ¶
type Runner interface {
Run(args ...Arg) (CommandOutput, error)
}
Runner runs a git subcommand and returns its standard output.