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 ¶
- Variables
- func AddWorktree(ctx context.Context, repo, path, branch string) error
- func Apply(ctx context.Context, dir, patchFile string) error
- func ApplyCheck(ctx context.Context, dir, patchFile string) error
- func Archive(ctx context.Context, dir, rev, dest string) error
- func Available() bool
- func Clone(ctx context.Context, remote, dest string) error
- func CommitAll(ctx context.Context, dir, message string) error
- func HasTracked(ctx context.Context, dir string) bool
- func HeadSHA(ctx context.Context, dir string) (string, error)
- func IsClean(ctx context.Context, dir string) (bool, error)
- func Log(ctx context.Context, dir, path string, n int) (string, error)
- func OpenPR(ctx context.Context, req PRRequest) (string, error)
- func Prefix(ctx context.Context, dir string) (string, error)
- func RevList(ctx context.Context, dir, good, bad string) ([]string, error)
- func Show(ctx context.Context, dir, rev, path string) (string, error)
- func Status(ctx context.Context, dir string) (string, error)
- func TopLevel(ctx context.Context, dir string) (string, error)
- func Tracked(ctx context.Context, dir string, paths ...string) bool
- type PRRequest
Constants ¶
This section is empty.
Variables ¶
var ErrNotRepo = errors.New("not a git repository")
ErrNotRepo is returned when a directory is not inside a git work tree.
Functions ¶
func AddWorktree ¶
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 ¶
Apply applies a unified diff in dir. It works in a plain directory too, not only inside a repository.
func ApplyCheck ¶
ApplyCheck reports whether a unified diff applies cleanly in dir.
func Archive ¶
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 Clone ¶
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 ¶
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 ¶
HasTracked reports whether dir contains at least one tracked file.
func Log ¶
Log returns up to n one-line history entries for path (or the whole repository when path is empty).
func OpenPR ¶
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 ¶
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 Status ¶
Status returns `git status --porcelain` output. An empty string means the work tree is clean.
func Tracked ¶
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.