gitcommand

package
v2.0.0-...-00053fb Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gitcommand reads repository state and runs Git commands with the supplied context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(ctx context.Context, git, root string, args ...string) *exec.Cmd

func ParseIndexModes

func ParseIndexModes(output string) (map[string]string, error)

func ParseStatusPaths

func ParseStatusPaths(output string) ([]string, error)

ParseStatusPaths reads the paths of `git status --porcelain=v1 -z` output. For a rename or copy it returns the new path and skips the original one.

Types

type Index

type Index struct {
	Modes map[string]string
	Path  string
}

Index is a read-only snapshot of the prospective tree and its watcher input.

func ReadIndex

func ReadIndex(ctx context.Context, root string) (result Index, err error)

type Output

type Output struct {
	Stdout []byte
	Stderr []byte
}

Output contains a Git query's separate output streams, including warnings written to stderr when Git exits successfully.

func Query

func Query(ctx context.Context, git, root string, environment []string, args ...string) (Output, error)

Query runs one local Git query with a deadline and bounded pipe draining. A nil environment uses Command's repository environment; a supplied environment replaces it so discovery can preserve its filesystem and pathspec settings.

type Worktree

type Worktree struct {
	// Head is the full commit ID HEAD names. It is empty before the first commit.
	Head string
	// Changes lists modified, added, deleted, renamed and untracked paths
	// relative to the repository root, with forward slashes, in Git's order.
	// Ignored files are not listed.
	Changes []string
}

Worktree is the commit a repository's HEAD names and the paths that differ from it in the index or working tree.

func ReadWorktree

func ReadWorktree(ctx context.Context, root string) (Worktree, error)

ReadWorktree reads HEAD and the uncommitted changes of the repository at root with two local Git queries. It does not fetch, prompt or run the repository's fsmonitor.

func (Worktree) Dirty

func (w Worktree) Dirty() bool

Dirty reports whether any path differs from HEAD.

Jump to

Keyboard shortcuts

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