Documentation
¶
Overview ¶
Package git provides filesystem and shell helpers for interacting with git repositories. All git command-line invocations in the CLI live here; callers wrap the typed errors with CLI-flavored hints at the boundary.
Index ¶
- Variables
- func BranchExistsOnRemote(branch string) bool
- func CanonicalURL(rawURL string) string
- func CurrentBranch() (string, error)
- func HeadRevision() (string, error)
- func IsRepo() bool
- func Push(branch string) error
- func RemoteForBranch(branch string) string
- func RepoPath(rawURL string) string
- func RepoRoot(start string) (string, bool)
- func ResolveRevision(rev string) (string, error)
- func UncommittedDiff() ([]byte, error)
- func UntrackedFiles() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDetachedHEAD = errors.New("detached HEAD: not on a branch")
ErrDetachedHEAD is returned by CurrentBranch when the working tree is in detached-HEAD state.
Functions ¶
func BranchExistsOnRemote ¶
BranchExistsOnRemote reports whether branch exists on its configured remote.
func CanonicalURL ¶
CanonicalURL reduces any supported git remote URL form (SSH short, ssh://, http(s)://) to "host/org/repo", or "" if unparseable.
func CurrentBranch ¶
CurrentBranch returns the current branch's short name; ErrDetachedHEAD when on no branch.
func IsRepo ¶
func IsRepo() bool
IsRepo reports whether the current working directory is inside a git working tree.
func RemoteForBranch ¶
RemoteForBranch returns the configured remote for branch, defaulting to "origin".
func RepoPath ¶
RepoPath extracts the "org/repo" path component from any supported git URL form, or "".
func RepoRoot ¶
RepoRoot returns the absolute path of the .git-containing ancestor of start, or ("", false) outside a working tree.
func ResolveRevision ¶
ResolveRevision returns the SHA for rev (full or short).
func UncommittedDiff ¶
UncommittedDiff returns `git diff HEAD` output, including untracked files via a transient intent-to-add.
func UntrackedFiles ¶
UntrackedFiles returns files reported by `git ls-files --others --exclude-standard`.
Types ¶
This section is empty.