Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGitRepo ¶
IsGitRepo reports whether cwd is inside a git repository. It returns false (without an error) when git is unavailable or the directory is not tracked by git.
func IsWorktreeRoot ¶
IsWorktreeRoot reports whether dir is the root of a git worktree
Types ¶
type Worktree ¶
type Worktree struct {
// Path is the absolute filesystem path to the worktree.
Path string
// Branch is the checked-out branch name (e.g. "refs/heads/main").
// Empty string for detached HEAD worktrees.
Branch string
// HEAD is the commit SHA the worktree is currently on.
HEAD string
// IsBare is true when the worktree is a bare clone.
IsBare bool
}
Worktree represents a single git worktree entry.
func CurrentWorktree ¶
CurrentWorktree returns the Worktree entry that corresponds to cwd, or an error if it cannot be determined.
func ListWorktrees ¶
ListWorktrees returns all worktrees for the repository that contains cwd. The list is parsed from the output of `git worktree list --porcelain`.
func (Worktree) ShortBranch ¶
ShortBranch returns the branch name with the "refs/heads/" prefix stripped, or "(detached)" when the worktree is in detached HEAD state.