Documentation
¶
Index ¶
- func BranchExists(dir, branch string) bool
- func Checkout(dir, branch string) error
- func CommitExists(dir, rev string) bool
- func CommitsBehind(dir, baseCommit, targetRef string) (int, error)
- func CreateWorktree(repoDir, worktreePath, branch string) error
- func CurrentBranch(dir string) (string, error)
- func DiffFile(dir, baseRef, path string) (string, error)
- func DiffFileRange(dir, baseRef, branchRef, path string) (string, error)
- func DiffNameStatus(dir, baseRef string) (map[string]string, error)
- func DiffNameStatusRange(dir, baseRef, branchRef string) (map[string]string, error)
- func DiffStat(dir, baseRef string) (added, removed int, err error)
- func EffectiveTarget(dir, target string) string
- func Fetch(dir string) error
- func FilterLineEndingWarnings(stderr string) string
- func GetCommitSubjects(dir, base string) ([]string, error)
- func HasRemote(dir string) bool
- func IsClean(dir string) (bool, error)
- func IsPushed(dir string) (bool, error)
- func ListRefs(dir string, patterns ...string) (map[string]string, error)
- func LocalPush(dir, targetBranch string) error
- func MergeBase(dir, ref1, ref2 string) (string, error)
- func MergeConflictFiles(dir, targetRef, headRef string) ([]string, error)
- func Output(dir string, args ...string) (string, error)
- func OverlappingFiles(dir, baseCommit, workerHead, targetRef string) ([]string, error)
- func RebaseOnto(dir, target string) error
- func ResetHard(dir string) error
- func ResolveDiffBase(dir string, branchRef, baseBranch string) (string, error)
- func Run(dir string, args ...string) error
- func RunQuiet(dir string, args ...string) error
- func RunSilent(dir string, args ...string) error
- func RunWithStderrFilter(dir string, stderrFilter func(string) string, args ...string) error
- func SetupBranch(dir string, t *task.Task, baseCommit string) error
- func ShowDiffStat(dir, commit string) (added, removed int, ok bool, err error)
- func SquashCommits(dir, mergeBase, message string) error
- func Switch(dir, branch, startPoint string) error
- type DiffFileStat
- type IntegrationReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists in the repository.
func CommitExists ¶
CommitExists returns whether rev resolves to a commit object.
func CommitsBehind ¶
CommitsBehind returns how many commits targetRef is ahead of baseCommit. Equivalent to: git rev-list --count <baseCommit>..<targetRef>
func CreateWorktree ¶
CreateWorktree creates a git worktree.
func CurrentBranch ¶
CurrentBranch returns the current branch name.
func DiffFileRange ¶
DiffFileRange returns the unified diff for a single file path for base..branch.
func DiffNameStatus ¶
DiffNameStatus returns per-file status codes compared to baseRef. Includes both committed changes on the current branch and uncommitted changes.
Output format: - <status>\t<path> - Renames/copies: R<score>\t<old>\t<new> (we return status "R" for <new>)
func DiffNameStatusRange ¶
DiffNameStatusRange returns per-file status codes for base..branch.
func DiffStat ¶
DiffStat returns lines added and removed compared to baseRef. Includes both committed changes on the current branch and uncommitted changes.
func EffectiveTarget ¶
EffectiveTarget returns target or origin/target if origin is ahead.
Note: This is used for *observation/detection* (e.g. noticing merges that happened upstream after a fetch), not for preferring remotes during user-facing operations.
func FilterLineEndingWarnings ¶
FilterLineEndingWarnings removes common git line-ending conversion warnings.
func GetCommitSubjects ¶
GetCommitSubjects returns commit subjects from base..HEAD.
func ListRefs ¶
ListRefs returns a map of full refname -> object SHA for the given ref namespaces/patterns.
Example patterns: - "refs/heads" - "refs/remotes/origin"
It runs a single `git for-each-ref` command and is intended to be fast.
func LocalPush ¶
LocalPush fast-forwards targetBranch to current HEAD via local push. Uses receive.denyCurrentBranch=updateInstead to allow pushing to a checked-out branch. This works even if targetBranch is checked out in the main worktree.
func MergeConflictFiles ¶
MergeConflictFiles returns the list of files that would conflict when merging headRef into targetRef.
This is a non-mutating check intended for preflight/status displays. It uses `git merge-tree` to simulate the merge and only reports files when git reports a conflict.
func OverlappingFiles ¶
OverlappingFiles returns files changed in both: - baseCommit..workerHead (worker changes) - baseCommit..targetRef (base branch changes)
This is a heuristic for potential merge conflicts.
func RebaseOnto ¶
RebaseOnto rebases current branch onto target. Aborts and returns error on conflict. On conflict, returns extracted CONFLICT lines (if any).
func ResolveDiffBase ¶
ResolveDiffBase returns the base commit to diff against.
Always compute merge-base between branchRef (e.g. "HEAD" or the task branch) and the local baseBranch.
func RunWithStderrFilter ¶
RunWithStderrFilter runs a git command, streaming stdout and filtering stderr (on success only). This is useful for removing known-benign warnings that would otherwise pollute CLI output.
If the command fails, stderr is not filtered.
func SetupBranch ¶
SetupBranch sets up the git branch for a task (local-first).
func ShowDiffStat ¶
ShowDiffStat returns lines added/removed for a single commit (like `git show --numstat`). If the commit does not exist, ok is false and err is nil.
func SquashCommits ¶
SquashCommits soft-resets to mergeBase and commits with message. All changes since mergeBase are staged and committed as a single commit.
Types ¶
type DiffFileStat ¶
type DiffFileStat struct {
Path string
Added int
Removed int
Binary bool
Status string // from `git diff --name-status` (e.g. A/M/D/R/C/T/U)
}
func DiffNumstat ¶
func DiffNumstat(dir, baseRef string) ([]DiffFileStat, error)
DiffNumstat returns per-file diff stats compared to baseRef. Includes both committed changes on the current branch and uncommitted changes.
func DiffNumstatRange ¶
func DiffNumstatRange(dir, baseRef, branchRef string) ([]DiffFileStat, error)
DiffNumstatRange returns per-file diff stats for base..branch.
type IntegrationReason ¶
type IntegrationReason string
IntegrationReason describes why a branch is considered integrated into target.
const ( IntegratedSameCommit IntegrationReason = "same_commit" // Branch HEAD == target HEAD IntegratedAncestor IntegrationReason = "ancestor" // Branch is ancestor of target IntegratedNoAddedChanges IntegrationReason = "no_changes" // Three-dot diff is empty IntegratedTreesMatch IntegrationReason = "trees_match" // Same file tree, different history IntegratedMergeAddsNothing IntegrationReason = "merge_adds_nothing" // Merge simulation produces same tree )
func IsIntegrated ¶
func IsIntegrated(dir, branch, target string) IntegrationReason
IsIntegrated checks if branch's changes are integrated into target. Returns the reason if integrated, empty string if not. Checks are ordered by cost (cheapest first).