Documentation
¶
Index ¶
- Variables
- func CreateBundle(base, cwd string) ([]byte, error)
- func CurrentBranch() (string, error)
- func GeneratePatch(base string) (string, error)
- func HeadRef(cwd string) (string, error)
- func HeadRefCtx(ctx context.Context, cwd string) (string, error)
- func IsBranchPushed() bool
- func MergeBase() (string, error)
- func RepoRoot(from string) (string, error)
- func TopLevelCtx(ctx context.Context, dir string) string
Constants ¶
This section is empty.
Variables ¶
var ErrNoOriginHEAD = errors.New("origin/HEAD is not set")
ErrNoOriginHEAD is returned by MergeBase when the upstream tracking branch is set but origin/HEAD is not — a common state after git init + push without fetch.
Functions ¶
func CreateBundle ¶ added in v0.7.122
CreateBundle creates a git bundle from base..HEAD in the repo at cwd and returns the raw bytes. If base is empty, the full history up to HEAD is bundled.
func CurrentBranch ¶
CurrentBranch returns the current git branch name. Returns an error if in detached HEAD state or not in a git repo.
func GeneratePatch ¶
GeneratePatch generates a binary diff from the given base commit, including untracked files. It temporarily stages untracked files with git add -N and resets them after generating the diff.
func HeadRef ¶ added in v0.7.122
HeadRef returns the SHA of the current HEAD commit in the repo at cwd.
func HeadRefCtx ¶ added in v0.7.138
HeadRefCtx returns the SHA of the current HEAD commit in the repo at cwd, honouring ctx for cancellation/timeout.
func IsBranchPushed ¶ added in v0.7.1
func IsBranchPushed() bool
IsBranchPushed returns true if the current branch exists on the remote (i.e. refs/remotes/origin/<branch> is present locally).
func MergeBase ¶
MergeBase returns a commit SHA that the remote is guaranteed to have. Tries merge-base between upstream and origin/HEAD first, falls back to origin/HEAD.
Types ¶
This section is empty.