Documentation
¶
Overview ¶
Package engine is the LazyGit-backed implementation of some of gitworkbench.Runner's capabilities (2026-11-12 decision): LazyGit's command layer (pkg/commands) with gitworkbench's runner policy laid over it.
Hard rules:
- this is the only package of the family that imports lazygit, and no lazygit type leaves it: every result is a gitworkbench model;
- every subprocess goes through policyRunner (policy.go), never through LazyGit's own runner;
- LazyGit's user configuration is not read: the defaults of config.NewDummyAppConfig apply, so a user's lazygit config cannot change what Solco Git does;
- a capability lands here only when the same real-repository test passes on this path and on the argv path.
Index ¶
- func RunDaemon() bool
- type Engine
- func (e *Engine) AmendTo(ctx context.Context, root, commit string) error
- func (e *Engine) CherryPickCommits(ctx context.Context, root string, hashes []string) error
- func (e *Engine) Close()
- func (e *Engine) CreateBranch(ctx context.Context, root, name, base string) error
- func (e *Engine) CreateTag(ctx context.Context, root, name, ref string) error
- func (e *Engine) DeleteBranch(ctx context.Context, root, name string) error
- func (e *Engine) DeleteTag(ctx context.Context, root, name string) error
- func (e *Engine) ListBranches(ctx context.Context, root string) ([]gitworkbench.Branch, error)
- func (e *Engine) ListTags(ctx context.Context, root string) ([]gitworkbench.Tag, error)
- func (e *Engine) ListWorktrees(ctx context.Context, root string) ([]gitworkbench.Worktree, error)
- func (*Engine) Name() string
- func (e *Engine) PatchSource(ctx context.Context, root, commit, path, previousPath string) ([]gitworkbench.PatchSourceLine, error)
- func (e *Engine) RenameBranch(ctx context.Context, root, name, to string) error
- func (e *Engine) RewriteHistory(ctx context.Context, root string, op gitworkbench.HistoryOp) error
- func (e *Engine) RewriteWithPatch(ctx context.Context, root string, op gitworkbench.PatchOp) error
- func (e *Engine) StashApply(ctx context.Context, root string, index int) error
- func (e *Engine) StashDrop(ctx context.Context, root string, index int) error
- func (e *Engine) StashList(ctx context.Context, root string) ([]gitworkbench.Stash, error)
- func (e *Engine) StashPop(ctx context.Context, root string, index int) error
- func (e *Engine) StashPush(ctx context.Context, root, message string) error
- func (e *Engine) SwitchBranch(ctx context.Context, root, name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunDaemon ¶
func RunDaemon() bool
RunDaemon serves the one case where Git runs this very program as its editor: LazyGit's rebase commands set GIT_SEQUENCE_EDITOR to the running executable and describe the todo change in the environment. It reports whether this process was such a call; when true the work is done and the caller must return from main without starting anything else. A failure exits the process with status 1 and a line on stderr, which Git turns into a failed rebase.
Call it first thing in main (before any lock, window or log file) and in a test binary's TestMain: the environment variable is the whole protocol.
Types ¶
type Engine ¶
type Engine struct {
// Commands, when set before the first call, receives every command the
// engine runs (the same log as Runner.Commands).
Commands *gitworkbench.CommandLog
// contains filtered or unexported fields
}
Engine serves gitworkbench.Backend capabilities from LazyGit's command layer. One Engine holds one session per repository root.
func New ¶
func New() *Engine
New returns an Engine. Install it with `runner.Backend = engine.New()`.
func (*Engine) CherryPickCommits ¶
CherryPickCommits applies the commits to HEAD, oldest first. LazyGit takes newest first and reverses; the commits are only named, so a stub commit with the hash is enough (the Runner has already refused merges).
func (*Engine) Close ¶
func (e *Engine) Close()
Close removes the sessions' temporary directories. The Engine stays usable: the next call makes a new session.
func (*Engine) CreateBranch ¶
func (*Engine) DeleteBranch ¶
func (*Engine) ListBranches ¶
ListBranches reads the local branches through LazyGit's BranchLoader and shapes them like the argv path does: sorted by name, no detached-HEAD pseudo-branch and no unborn branch, the upstream as "remote/branch", the head as a 7-character short hash.
func (*Engine) ListTags ¶
ListTags reads the tags newest creation first through LazyGit's TagLoader.
func (*Engine) ListWorktrees ¶
ListWorktrees reads the work trees through LazyGit's WorktreeLoader. The loader moves the work tree it is pinned to to the top of the list, so it is asked through the main work tree's session: Git's own order (main first, then the linked ones as Git lists them) comes out whichever work tree the caller is in. A work tree that is mid-rebase has its branch named by LazyGit; the argv path calls it detached, so that is put back.
func (*Engine) PatchSource ¶
func (e *Engine) PatchSource(ctx context.Context, root, commit, path, previousPath string) ([]gitworkbench.PatchSourceLine, error)
PatchSource returns the diff of one file in a commit exactly as LazyGit's patch builder reads it, so the line indices of a selection mean the same thing here and in RewriteWithPatch.
func (*Engine) RenameBranch ¶
func (*Engine) RewriteHistory ¶
RewriteHistory applies op through LazyGit's rebase commands.
func (*Engine) RewriteWithPatch ¶
RewriteWithPatch applies op through LazyGit's custom patch commands.
func (*Engine) StashApply ¶
func (*Engine) StashList ¶
StashList lists the entries newest first. LazyGit's loader knows the stash commit and its message but not the commit the stash was made on, so the bases are asked in one batch: `rev-parse <stash>^ …`. The loader reports no error of its own (a failing `git stash list` reads as an empty list); the session has already proved the directory is a repository.