Documentation
¶
Overview ¶
Package git wraps the git CLI behind two small interfaces: Runner (executes arbitrary git commands) and Client (high-level operations the rest of the codebase actually needs).
Both interfaces accept context for cancellation. Callers that need to test git interactions should inject a mock Runner rather than shelling out.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
IsRepo(dir string) bool
Init(ctx context.Context, dir string) error
Add(ctx context.Context, dir, path string) error
Commit(ctx context.Context, dir, msg string) (hash string, err error)
Status(ctx context.Context, dir string) (dirty bool, lines []string, err error)
HeadHash(ctx context.Context, dir string) (string, error)
EnsureConfig(ctx context.Context, dir, key, value string) error
// CloneOrPull clones url@ref into dest if dest is not already a git
// repository, otherwise runs `git fetch && git checkout ref` in place.
// Used by `adept init --from <git-url>` to bootstrap a library remote.
CloneOrPull(ctx context.Context, url, ref, dest string) error
}
Client is the high-level surface used by callers.
type Runner ¶
Runner executes a git command with the given working directory and args.
Implementations MUST NOT panic on non-zero exit codes; they should populate Result and return a non-nil error so callers can distinguish process failures (e.g. "git not installed") from command failures (e.g. "fatal: not a git repository").
func NewExecRunner ¶
NewExecRunner returns a Runner backed by os/exec. Pass "" to default to "git" on $PATH.