Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dirs ¶ added in v0.143.1
Dirs exposes the memoised layout resolution to callers that need the paths themselves rather than a State — a live dashboard keying a cache on the files git would read (HEAD, packed-refs, a branch ref) has to know where they are, and re-forking rev-parse to re-learn that on every poll is the cost this package's cache already exists to avoid.
Types ¶
type RebaseStuck ¶
type RebaseStuck struct {
Reason RebaseStuckReason
// StoppedSHA is the commit at which the rebase paused (empty if unknown).
StoppedSHA string
// LastDoneOp is the verb of the last entry in `done` ("pick", "edit",
// "exec", "reword", "break", ...). Empty if `done` is missing or empty.
LastDoneOp string
// LastDoneArg is the rest of the last `done` line after the verb — for
// `pick` this is a short sha + comment, for `exec` it is the command.
LastDoneArg string
}
RebaseStuck carries the classification plus the signals that drove it, so callers can build a useful message without re-reading the git dir.
func ClassifyRebaseStuck ¶
func ClassifyRebaseStuck(state *State) RebaseStuck
ClassifyRebaseStuck inspects a known rebase-merge/rebase-apply state and returns the reason it is paused. For non-rebase states (or when the rebase is progressing normally) it returns RebaseStuckNone.
The caller is expected to have already confirmed there are zero unmerged paths — this function does not look at the work tree.
type RebaseStuckReason ¶
type RebaseStuckReason int
RebaseStuckReason classifies why a rebase has paused with no merge conflicts.
const ( // RebaseStuckNone — not stuck, or not a rebase state. Either the rebase is // progressing normally or the state isn't RebaseMerge/RebaseApply. RebaseStuckNone RebaseStuckReason = iota // RebaseStuckEmptyCommit — picked commit produced an empty/redundant patch // against the new base. git stops here so the user can decide // (--skip vs --continue with --allow-empty). RebaseStuckEmptyCommit // RebaseStuckEdit — explicit `edit` / `reword` / `break` line in the todo // pauses the rebase for amending. RebaseStuckEdit // RebaseStuckExec — `exec` line failed; rebase pauses until the user fixes // the command output and runs --continue. RebaseStuckExec // RebaseStuckUnknown — rebase is paused with no unmerged paths but the // signals don't match a known category (rebase-apply backend, malformed // state dir, future git versions, etc.). RebaseStuckUnknown )
func (RebaseStuckReason) String ¶
func (r RebaseStuckReason) String() string
String returns a stable identifier suitable for messages and tests.
type State ¶
type State struct {
Kind StateKind
GitDir string // 일반 git dir (.git)
CommonDir string // common dir (worktree 대응)
// Rebase-specific fields (only populated for StateRebaseMerge/RebaseApply)
HeadName string // original branch (e.g. "refs/heads/feat/x")
Onto string // target ref
OrigHead string // HEAD sha before rebase started
Current int // current step (1-based)
Total int // total step count
}
State carries details about the in-progress operation.
func Detect ¶
Detect inspects the current working tree's git directory and returns State. If workDir == "", uses current working directory. Returns StateNone when no operation is in progress.
func DetectFromGitDir ¶
DetectFromGitDir performs the same inspection given a known git dir. Useful for tests — skips `git rev-parse` call.
type StateKind ¶
type StateKind int
StateKind represents which in-progress operation git is currently performing.
const ( StateNone StateKind = iota StateRebaseMerge // interactive rebase / merge backend (.git/rebase-merge) StateRebaseApply // am / patch-based rebase (.git/rebase-apply) StateMerge // merge conflict (.git/MERGE_HEAD) StateCherryPick // cherry-pick in progress (.git/CHERRY_PICK_HEAD) StateRevert // revert in progress (.git/REVERT_HEAD) StateBisect // bisect in progress (.git/BISECT_LOG) )