gitx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 11 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 gitx wraps the git command line for the few operations Spackle needs: reading the commit, cloning a target, creating a worktree for fixes, reading history, and bisecting.

Every call passes arguments as a vector, never through a shell, and disables hooks and prompts so a hostile repository cannot run code or block the run by asking for credentials.

Index

Constants

This section is empty.

Variables

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

ErrNotRepo is returned when a directory is not inside a git work tree.

Functions

func AddWorktree

func AddWorktree(ctx context.Context, repo, path, branch string) error

AddWorktree creates a new branch at HEAD checked out in a new worktree at path. The caller's working tree and index are not touched.

func Apply

func Apply(ctx context.Context, dir, patchFile string) error

Apply applies a unified diff in dir. It works in a plain directory too, not only inside a repository.

func ApplyCheck

func ApplyCheck(ctx context.Context, dir, patchFile string) error

ApplyCheck reports whether a unified diff applies cleanly in dir.

func Archive

func Archive(ctx context.Context, dir, rev, dest string) error

Archive exports the tree at rev into dest (which must exist), without any .git directory. It is how a specific commit is handed to the sandbox.

func Available

func Available() bool

Available reports whether git is on PATH.

func Clone

func Clone(ctx context.Context, remote, dest string) error

Clone makes a shallow clone of remote into dest. Submodules are not fetched: they are separate code the operator did not name as the target.

func CommitAll

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

CommitAll stages everything in dir and commits with the given message. It is only ever called inside a Spackle worktree, never the operator's working tree.

func HasTracked

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

HasTracked reports whether dir contains at least one tracked file.

func HeadSHA

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

HeadSHA returns the full commit hash of HEAD, or ErrNotRepo.

func IsClean

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

IsClean reports whether the work tree has no uncommitted changes.

func Log

func Log(ctx context.Context, dir, path string, n int) (string, error)

Log returns up to n one-line history entries for path (or the whole repository when path is empty).

func OpenPR

func OpenPR(ctx context.Context, req PRRequest) (string, error)

OpenPR pushes the branch to the "origin" remote and opens a pull request with the GitHub CLI. It is only called when the operator passed --pr: it is the one place Spackle writes anywhere other than the local machine.

The pull request is opened as a draft. A patch written by a model should be read by a person before it is merged, and a draft says so.

func Prefix

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

Prefix returns the path of dir relative to the top of its work tree, with forward slashes and no trailing slash ("" at the top). Asking git avoids comparing path spellings, which differ on Windows (short names, case).

func RevList

func RevList(ctx context.Context, dir, good, bad string) ([]string, error)

RevList returns the commits from good (exclusive) to bad (inclusive), oldest first.

func Show

func Show(ctx context.Context, dir, rev, path string) (string, error)

Show returns the patch of one commit, limited to path when given.

func Status

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

Status returns `git status --porcelain` output. An empty string means the work tree is clean.

func TopLevel

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

TopLevel returns the root of the work tree containing dir.

func Tracked

func Tracked(ctx context.Context, dir string, paths ...string) bool

Tracked reports whether every given path (relative to dir) is tracked by git. A directory can sit inside some unrelated repository without being part of it (a temp folder under a home directory that is itself a repository, for example). Spackle only treats a target as "in git" when its files are tracked.

Types

type PRRequest

type PRRequest struct {
	// Dir is the worktree that holds the branch.
	Dir    string
	Branch string
	Title  string
	Body   string
}

PRRequest describes a pull request to open for a fix branch.

Jump to

Keyboard shortcuts

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