Documentation
¶
Overview ¶
Package git shells out to the system git binary.
Index ¶
- func StackParentConfigKey(branch string) string
- type RemoteRelation
- type Repo
- func (r *Repo) Config(key, value string) error
- func (r *Repo) ConfigGet(key string) string
- func (r *Repo) ConfigUnset(key string) error
- func (r *Repo) CurrentBranch() (string, error)
- func (r *Repo) DefaultBranch() string
- func (r *Repo) DeleteBranch(name string) error
- func (r *Repo) FFBranch(branch string) error
- func (r *Repo) FetchOrigin() error
- func (r *Repo) ForceDeleteBranch(name string) error
- func (r *Repo) GetStackParent(branch string) string
- func (r *Repo) GitDir() (string, error)
- func (r *Repo) HasOrigin() bool
- func (r *Repo) IsAncestor(ancestor, descendant string) bool
- func (r *Repo) LocalBranchExists(name string) bool
- func (r *Repo) LocalBranches() ([]string, error)
- func (r *Repo) MergeBase(a, b string) (string, error)
- func (r *Repo) MergeBaseForkPoint(parentRef, branchRef string) (string, error)
- func (r *Repo) OriginBranchExists(name string) bool
- func (r *Repo) PushForceWithLease(branch string) error
- func (r *Repo) PushUpstream(branch string) error
- func (r *Repo) RebaseOnto(onto, upstream, branch string) error
- func (r *Repo) RebaseOntoOrigin(branch string) error
- func (r *Repo) RebaseOntoQuiet(onto, upstream, branch string) error
- func (r *Repo) RefExists(name string) bool
- func (r *Repo) RemoteRelationOf(branch string) RemoteRelation
- func (r *Repo) RequireClean() error
- func (r *Repo) RequireNoRebase() error
- func (r *Repo) RequireRepo() error
- func (r *Repo) ResolveRef(name string) (string, error)
- func (r *Repo) RevListCount(revRange string) (int, error)
- func (r *Repo) RevListOneline(revRange string) (string, error)
- func (r *Repo) RevParse(rev string) (string, error)
- func (r *Repo) RunInteractive(args ...string) error
- func (r *Repo) SetStackParent(branch, parent string) error
- func (r *Repo) ShortSHA(rev string) (string, error)
- func (r *Repo) StatusPorcelainUno() (string, error)
- func (r *Repo) Switch(name string) error
- func (r *Repo) SwitchCreate(name, startRef string) error
- func (r *Repo) UnsetStackParent(branch string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StackParentConfigKey ¶
StackParentConfigKey is the git config key for an explicit stack parent.
Types ¶
type RemoteRelation ¶
type RemoteRelation string
RemoteRelation describes local tip vs origin/<branch>.
const ( RelNone RemoteRelation = "none" RelInSync RemoteRelation = "in-sync" RelBehind RemoteRelation = "behind" RelAhead RemoteRelation = "ahead" RelDiverged RemoteRelation = "diverged" )
type Repo ¶
type Repo struct {
// Dir is the working tree path. Empty means current directory.
Dir string
}
Repo is a git repository working directory.
func (*Repo) ConfigUnset ¶
ConfigUnset removes a local config key (no error if missing).
func (*Repo) CurrentBranch ¶
CurrentBranch returns the current branch name (fails on detached HEAD).
func (*Repo) DefaultBranch ¶
DefaultBranch returns the trunk branch name (origin/HEAD, else main/master).
func (*Repo) DeleteBranch ¶
DeleteBranch runs git branch -d (safe; refuses unmerged).
func (*Repo) FetchOrigin ¶
FetchOrigin runs git fetch origin (no-op if no origin).
func (*Repo) ForceDeleteBranch ¶
ForceDeleteBranch runs git branch -D (force local delete).
func (*Repo) GetStackParent ¶
GetStackParent reads branch.<name>.gitstack-parent.
func (*Repo) IsAncestor ¶
IsAncestor reports whether ancestor is an ancestor of descendant.
func (*Repo) LocalBranchExists ¶
LocalBranchExists checks refs/heads/<name>.
func (*Repo) LocalBranches ¶
LocalBranches lists short names under refs/heads/.
func (*Repo) MergeBaseForkPoint ¶
MergeBaseForkPoint returns git merge-base --fork-point result, or error.
func (*Repo) OriginBranchExists ¶
OriginBranchExists checks refs/remotes/origin/<name>.
func (*Repo) PushForceWithLease ¶
PushForceWithLease pushes branch with --force-with-lease.
func (*Repo) PushUpstream ¶
PushUpstream sets upstream and pushes.
func (*Repo) RebaseOnto ¶
RebaseOnto runs: git rebase --onto onto upstream branch
func (*Repo) RebaseOntoOrigin ¶
RebaseOntoOrigin rebases branch onto origin/<branch> (pull --rebase). When branch is not HEAD, git checks it out first.
func (*Repo) RebaseOntoQuiet ¶
RebaseOntoQuiet runs rebase without attaching to terminal (for tests).
func (*Repo) RemoteRelationOf ¶
func (r *Repo) RemoteRelationOf(branch string) RemoteRelation
RemoteRelationOf classifies local vs origin for a local branch.
func (*Repo) RequireClean ¶
RequireClean fails if tracked/staged changes exist (untracked OK).
func (*Repo) RequireNoRebase ¶
RequireNoRebase fails if a rebase is in progress.
func (*Repo) RequireRepo ¶
RequireRepo dies if not inside a git repository.
func (*Repo) ResolveRef ¶
ResolveRef prefers local heads, then origin/, then the name as-is.
func (*Repo) RevListCount ¶
RevListCount counts commits in range (exclusive..inclusive style args).
func (*Repo) RevListOneline ¶
RevListOneline returns oneline log for a range.
func (*Repo) RunInteractive ¶
RunInteractive runs git with the caller's stdout/stderr (for rebase UX).
func (*Repo) SetStackParent ¶
SetStackParent writes branch.<name>.gitstack-parent.
func (*Repo) StatusPorcelainUno ¶
StatusPorcelainUno returns porcelain status for tracked files only (-uno).
func (*Repo) SwitchCreate ¶
SwitchCreate creates and checks out a new branch from startRef.
func (*Repo) UnsetStackParent ¶
UnsetStackParent clears branch.<name>.gitstack-parent.