Documentation
¶
Overview ¶
Package git wraps the git plumbing commands wt shells out to.
Index ¶
- Constants
- func BranchDelete(mainDir, branch string) error
- func DefaultBranch(mainDir string) (name string, err error)
- func Fetch(mainDir string) error
- func IgnoredFiles(mainDir string) ([]string, error)
- func MainDir() (string, error)
- func RefExists(mainDir, ref string) bool
- func WorktreeAdd(mainDir, dir, branch, baseRef string) error
- func WorktreePrune(mainDir string) error
- func WorktreeRemove(mainDir, dir string) error
- type Worktree
Constants ¶
const DetachedBranch = "(detached)"
DetachedBranch is the sentinel Worktree.Branch value for a worktree checked out at a detached HEAD (no branch).
Variables ¶
This section is empty.
Functions ¶
func BranchDelete ¶
BranchDelete runs `git branch -d <branch>` in mainDir.
func DefaultBranch ¶
DefaultBranch returns the short name of origin's default branch (e.g. "main"), resolved from the local origin/HEAD symref. Returns "" if the symref simply isn't set (the common, benign case). err is non-nil only for an unexpected failure (e.g. git missing, repo corruption) — distinct from "not set" so callers can tell the two apart.
func IgnoredFiles ¶ added in v0.1.3
IgnoredFiles returns paths mainDir's gitignore rules ignore, relative to mainDir — from `git status --porcelain --ignored --untracked-files=all`. A directory that's entirely ignored is returned as one entry (its trailing slash stripped), not walked file by file.
func MainDir ¶
MainDir resolves the main checkout root, even when the current directory is inside a linked worktree. It shells out to `git rev-parse --git-common-dir` and returns the parent of that dir.
func WorktreeAdd ¶
WorktreeAdd runs `git worktree add <dir> -b <branch> <baseRef>` in mainDir.
func WorktreePrune ¶
WorktreePrune runs `git worktree prune` in mainDir.
func WorktreeRemove ¶
WorktreeRemove runs `git worktree remove <dir>` in mainDir.
Types ¶
type Worktree ¶
Worktree is one entry from `git worktree list`: its checkout path and the branch checked out there (DetachedBranch if none).
func WorktreeList ¶
WorktreeList returns all worktrees registered against mainDir (the main checkout included), parsed from `git worktree list --porcelain`.