gitutil

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gitutil provides minimal git helpers used by the Ralph loop: repo detection, working-tree dirtiness checks, and short status output.

Everything is implemented by shelling out to the `git` binary so we do not pick up a heavy dependency. All commands are run from a caller-supplied working directory.

Index

Constants

This section is empty.

Variables

View Source
var ErrGitNotFound = errors.New("git binary not found on PATH")

ErrGitNotFound indicates the `git` binary could not be located on PATH.

View Source
var ErrNotARepo = errors.New("not a git repository")

ErrNotARepo indicates the working directory is not inside a git repository.

Functions

func CommitAll

func CommitAll(ctx context.Context, dir, message string) (string, error)

CommitAll stages every change in dir and creates a commit with the given message. It returns the resulting commit's short SHA. ErrNotARepo is returned when dir is not inside a git repository. A clean working tree returns ("", nil) — there is nothing to commit.

func CreateTag

func CreateTag(ctx context.Context, dir, tag, message string) error

CreateTag creates an annotated tag pointing at HEAD. It is a no-op when the tag already exists.

func DiffStat

func DiffStat(ctx context.Context, dir string) (string, error)

DiffStat returns the output of `git diff --stat HEAD` for dir, capturing both staged and unstaged changes. An empty string means no diff. The "Bytes" field on Result holds the byte count of the captured diff.

func IsClean

func IsClean(ctx context.Context, dir string) (bool, error)

IsClean reports whether the working tree at dir has no uncommitted changes.

func IsRepo

func IsRepo(ctx context.Context, dir string) (bool, error)

IsRepo reports whether dir is inside a git repository. It returns ErrGitNotFound when git is unavailable.

func PorcelainStatus

func PorcelainStatus(ctx context.Context, dir string) (string, error)

PorcelainStatus returns the output of `git status --porcelain` for dir. An empty string means the working tree is clean. ErrNotARepo is returned when dir is not inside a git repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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