git

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func BranchExistsOnRemote(branch string) bool

BranchExistsOnRemote reports whether branch exists on its configured remote.

func CanonicalURL

func CanonicalURL(rawURL string) string

CanonicalURL reduces any supported git remote URL form (SSH short, ssh://, http(s)://) to "host/org/repo", or "" if unparseable.

func CurrentBranch

func CurrentBranch() (string, error)

CurrentBranch returns the current branch's short name; ErrDetachedHEAD when on no branch.

func HeadRevision

func HeadRevision() (string, error)

HeadRevision returns the SHA of HEAD.

func IsRepo

func IsRepo() bool

IsRepo reports whether the current working directory is inside a git working tree.

func Push

func Push(branch string) error

Push runs `git push -u <remote> <branch>` for the branch's configured remote.

func RemoteForBranch

func RemoteForBranch(branch string) string

RemoteForBranch returns the configured remote for branch, defaulting to "origin".

func RepoPath

func RepoPath(rawURL string) string

RepoPath extracts the "org/repo" path component from any supported git URL form, or "".

func RepoRoot

func RepoRoot(start string) (string, bool)

RepoRoot returns the absolute path of the .git-containing ancestor of start, or ("", false) outside a working tree.

func ResolveRevision

func ResolveRevision(rev string) (string, error)

ResolveRevision returns the SHA for rev (full or short).

func UncommittedDiff

func UncommittedDiff() ([]byte, error)

UncommittedDiff returns `git diff HEAD` output, including untracked files via a transient intent-to-add.

func UntrackedFiles

func UntrackedFiles() ([]string, error)

UntrackedFiles returns files reported by `git ls-files --others --exclude-standard`.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL