engine

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 23 Imported by: ? 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 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

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) AmendTo

func (e *Engine) AmendTo(ctx context.Context, root, commit string) error

AmendTo amends the commit with the staged changes through LazyGit.

func (*Engine) CherryPickCommits

func (e *Engine) CherryPickCommits(ctx context.Context, root string, hashes []string) error

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 (e *Engine) CreateBranch(ctx context.Context, root, name, base string) error

func (*Engine) CreateTag

func (e *Engine) CreateTag(ctx context.Context, root, name, ref string) error

func (*Engine) DeleteBranch

func (e *Engine) DeleteBranch(ctx context.Context, root, name string) error

func (*Engine) DeleteTag

func (e *Engine) DeleteTag(ctx context.Context, root, name string) error

func (*Engine) ListBranches

func (e *Engine) ListBranches(ctx context.Context, root string) ([]gitworkbench.Branch, error)

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

func (e *Engine) ListTags(ctx context.Context, root string) ([]gitworkbench.Tag, error)

ListTags reads the tags newest creation first through LazyGit's TagLoader.

func (*Engine) ListWorktrees

func (e *Engine) ListWorktrees(ctx context.Context, root string) ([]gitworkbench.Worktree, error)

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) Name

func (*Engine) Name() string

Name implements gitworkbench.Backend.

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 (e *Engine) RenameBranch(ctx context.Context, root, name, to string) error

func (*Engine) RewriteHistory

func (e *Engine) RewriteHistory(ctx context.Context, root string, op gitworkbench.HistoryOp) error

RewriteHistory applies op through LazyGit's rebase commands.

func (*Engine) RewriteWithPatch

func (e *Engine) RewriteWithPatch(ctx context.Context, root string, op gitworkbench.PatchOp) error

RewriteWithPatch applies op through LazyGit's custom patch commands.

func (*Engine) StashApply

func (e *Engine) StashApply(ctx context.Context, root string, index int) error

func (*Engine) StashDrop

func (e *Engine) StashDrop(ctx context.Context, root string, index int) error

func (*Engine) StashList

func (e *Engine) StashList(ctx context.Context, root string) ([]gitworkbench.Stash, error)

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.

func (*Engine) StashPop

func (e *Engine) StashPop(ctx context.Context, root string, index int) error

func (*Engine) StashPush

func (e *Engine) StashPush(ctx context.Context, root, message string) error

func (*Engine) SwitchBranch

func (e *Engine) SwitchBranch(ctx context.Context, root, name string) error

Jump to

Keyboard shortcuts

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