gitutil

package
v0.7.67 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func CurrentBranch() (string, error)

CurrentBranch returns the current git branch name. Returns an error if in detached HEAD state or not in a git repo.

func GeneratePatch

func GeneratePatch(base string) (string, error)

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

func MergeBase() (string, error)

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.

func RepoRoot

func RepoRoot(from string) (string, error)

RepoRoot returns the root directory of the current git repository by walking up from the given directory looking for .git/.

Types

This section is empty.

Jump to

Keyboard shortcuts

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