git

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureBaseline

func CaptureBaseline(ctx context.Context, r Runner, root string) (string, error)

func CommonDir

func CommonDir(ctx context.Context, r Runner, root string) (string, error)

func CurrentBranch

func CurrentBranch(ctx context.Context, r Runner, root string) (string, error)

CurrentBranch reports the checked-out branch name for a worktree. A detached HEAD has no branch, which is reported as an empty name rather than an error so session observation keeps working. The name is bounded and validated because it becomes shared coordination metadata.

func Fingerprint

func Fingerprint(ctx context.Context, r Runner, root, projectID string) (string, error)

func Hash

func Hash(entries []Entry) (string, error)

Types

type Change

type Change struct {
	Status  string `json:"status"`
	OldPath string `json:"oldPath,omitempty"`
}

type Entry

type Entry struct {
	Path   string `json:"path"`
	States States `json:"states"`
}

type Ignores

type Ignores struct {
	// contains filtered or unexported fields
}

Ignores answers whether Git ignores a path under one repository root, so the file watcher can prune ignored trees instead of watching them. On macOS the watcher's kqueue backend pins an open file descriptor for every watched directory and every file inside one for the life of the watch, so watching ignored build trees (node_modules and friends) exhausts the system file table. Pruning is therefore a resource-correctness requirement, not an optimization.

The bulk of the answer is captured once from ls-files at construction. Paths that appear after that snapshot — a fresh node_modules materializing during an install — are resolved with check-ignore on first sight and cached.

func NewIgnores

func NewIgnores(ctx context.Context, r Runner, root string) (*Ignores, error)

NewIgnores snapshots the ignored paths of the repository at root. root must be absolute, as the watcher hands absolute paths back for matching.

func (*Ignores) Ignored

func (ig *Ignores) Ignored(ctx context.Context, path string) bool

Ignored reports whether Git ignores path, consulting the snapshot first and falling back to check-ignore for paths the snapshot has never seen. Use it for paths created after construction; the verdict is cached.

func (*Ignores) Prune

func (ig *Ignores) Prune(path string) bool

Prune reports whether the snapshot recorded path as ignored. It never runs git, so it is safe to call once per directory of a large tree walk.

type Manifest

type Manifest struct {
	Baseline, Head, BaselineState string
	Entries                       []Entry
}

func Observe

func Observe(ctx context.Context, r Runner, root, baseline string) (Manifest, error)

type Runner

type Runner struct{}

type States

type States struct {
	Baseline *Change `json:"baseline,omitempty"`
	Index    *Change `json:"index,omitempty"`
	Worktree *Change `json:"worktree,omitempty"`
}

Jump to

Keyboard shortcuts

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