gitutil

package
v0.7.122 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 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 CreateBundle added in v0.7.122

func CreateBundle(base, cwd string) ([]byte, error)

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

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 HeadRef added in v0.7.122

func HeadRef(cwd string) (string, error)

HeadRef returns the SHA of the current HEAD commit in the repo at cwd.

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