Documentation
¶
Index ¶
- func AheadBehind(ctx context.Context, runner CommandRunner, path string) (ahead, behind int, hasUpstream bool, err error)
- func Dirty(ctx context.Context, runner CommandRunner, path string) (bool, error)
- func MergedBranches(ctx context.Context, runner CommandRunner, base string) ([]string, error)
- func RemoteBranchExists(ctx context.Context, runner CommandRunner, path, branch string) (exists, hasUpstream bool, err error)
- type CommandRunner
- type CommitInfo
- type ErrNotFound
- type ExecRunner
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AheadBehind ¶
func AheadBehind( ctx context.Context, runner CommandRunner, path string, ) (ahead, behind int, hasUpstream bool, err error)
AheadBehind returns the number of commits the branch at path is ahead of and behind its upstream. hasUpstream is false when no upstream is configured; this is not an error.
func MergedBranches ¶
MergedBranches returns local branches already merged into base. It excludes base itself and any branch whose tip points at exactly the same commit as base — such branches have no unique history yet (freshly created, or fast- forwarded with no subsequent activity) and are not safe to auto-prune, since a fresh worktree's work-in-progress has no commits to mark it distinct.
func RemoteBranchExists ¶
func RemoteBranchExists( ctx context.Context, runner CommandRunner, path, branch string, ) (exists, hasUpstream bool, err error)
RemoteBranchExists reports whether the branch at path has a configured upstream tracking ref and whether that remote still has the branch.
Returns (false, false, nil) when no upstream is configured — a local branch that was never pushed is not a "remote-gone" finding. Returns (false, true, nil) when an upstream is configured but the remote no longer has the branch.
Types ¶
type CommandRunner ¶
type CommitInfo ¶
type CommitInfo struct {
ShortSHA string `json:"sha"`
Subject string `json:"subject"`
Committed time.Time `json:"committed"`
}
func LastCommit ¶
func LastCommit(ctx context.Context, runner CommandRunner, path string) (CommitInfo, error)
type ErrNotFound ¶
type ErrNotFound struct {
Branch string
}
ErrNotFound is returned when no worktree matches the requested branch.
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type ExecRunner ¶
type ExecRunner struct{ Dir string }
ExecRunner runs commands with os/exec. An empty Dir inherits the process working directory, so a caller that stands in the repo needs no Dir at all.
type Worktree ¶
type Worktree struct {
Path string
Branch string // stripped of refs/heads/ prefix; "(detached)" when detached
IsMain bool // true when .git entry is a directory, not a file
Prunable bool // true when git considers the worktree stale (directory deleted)
PrunableReason string // git's human-readable reason, e.g. "gitdir file points to non-existent location"
}
func MainWorktree ¶
MainWorktree returns the worktree whose .git entry is a directory (the main repo).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package worktreetest provides shared test helpers for packages that depend on worktree.CommandRunner.
|
Package worktreetest provides shared test helpers for packages that depend on worktree.CommandRunner. |