gitcmd

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitcmd runs git in a repository for the commands that read the committed state beside the working tree: the default branch's ref, a file as the branch holds it, the tracked files under a directory, and a rename the index follows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRef

func DefaultRef(ctx context.Context, root, branch string) (ref, commit string, err error)

DefaultRef is the ref holding the default branch's tree: origin's copy of the branch when the repository has one (what a pull-request build compares against), else the local branch. Neither is an error: the committed state has to come from somewhere.

func InWorkTree

func InWorkTree(ctx context.Context, dir string) bool

InWorkTree reports whether dir is inside a git working tree: a directory that is not has no committed state to compare with, and a check over it says nothing.

func Output

func Output(ctx context.Context, root string, args ...string) (string, error)

Output runs one git command in the repository at root and returns its standard output; a failure carries what git said.

func Prefix

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

Prefix is dir's path from the repository's root, with a trailing slash, and empty at the root: what a path under dir is prefixed with to name it in a tree.

func Show

func Show(ctx context.Context, root, ref, path string) (content []byte, ok bool, err error)

Show reads the file at path (from the repository's root) as the ref's tree holds it. A ref whose tree has no such file is not an error: ok is false and nothing is read.

Types

This section is empty.

Jump to

Keyboard shortcuts

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