Help us shape the future of Go! Take the 2026 Go Developer Survey

runner

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package runner provides types for executing commands in a specific directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FetchRunner

type FetchRunner struct {
	// GitCommand is the git binary name/path. Defaults to "git" if empty.
	GitCommand string
	// Default fetches only the repository's default branch.
	Default bool
	// FetchFlags are additional arguments passed directly to "git fetch".
	FetchFlags []string
	// Inner executes git commands. Defaults to ProcessRunner{} if nil.
	Inner Runner
}

FetchRunner handles git fetch execution across repositories.

func (*FetchRunner) Run

func (f *FetchRunner) Run(ctx context.Context, dir string, _ []string, stdout, stderr io.Writer) error

Run executes the fetch command.

type GrepRunner

type GrepRunner = PathPrefixRunner

GrepRunner is an alias for PathPrefixRunner.

type PathPrefixRunner

type PathPrefixRunner struct {
	Inner Runner
	// RepoPath is the absolute path of the repository.
	RepoPath string
	// AbsPath controls whether output paths are absolute or relative to Root.
	AbsPath bool
	// Root is the repos root used to compute a relative prefix when AbsPath is false.
	Root string
}

PathPrefixRunner wraps another Runner to execute a command and prefix each output line with the repository path.

When AbsPath is true the prefix is the absolute RepoPath. When AbsPath is false the prefix is RepoPath relative to Root.

func (*PathPrefixRunner) Run

func (g *PathPrefixRunner) Run(ctx context.Context, dir string, command []string, stdout, stderr io.Writer) error

type ProcessRunner

type ProcessRunner struct{}

ProcessRunner executes commands as real OS processes.

func (ProcessRunner) Run

func (r ProcessRunner) Run(ctx context.Context, dir string, command []string, stdout, stderr io.Writer) error

type PullRunner

type PullRunner struct {
	// GitCommand is the git binary name/path. Defaults to "git" if empty.
	GitCommand string
	// SwitchDefault checks out the repository's default branch before pulling.
	SwitchDefault bool
	// SwitchBack restores the initial branch after pulling if SwitchDefault changed branches.
	SwitchBack bool
	// PullFlags are additional arguments passed directly to "git pull".
	PullFlags []string
	// Inner executes git commands. Defaults to ProcessRunner{} if nil.
	Inner Runner
}

PullRunner handles git pull execution with optional default branch checkout and branch restoration.

func (*PullRunner) Run

func (p *PullRunner) Run(ctx context.Context, dir string, _ []string, stdout, stderr io.Writer) error

Run executes the pull sequence.

type Runner

type Runner interface {
	Run(ctx context.Context, dir string, command []string, stdout, stderr io.Writer) error
}

Runner executes a command in dir, writing its stdout/stderr to the provided writers.

type TaskError

type TaskError struct {
	Dir      string
	Command  []string
	ExitCode int
	Err      error
}

TaskError annotates an execution error with the repository path, the executed command, and the process exit code.

func (*TaskError) Error

func (e *TaskError) Error() string

func (*TaskError) Unwrap

func (e *TaskError) Unwrap() error

type WorktreePruneRunner added in v0.4.0

type WorktreePruneRunner struct {
	// GitCommand is the git binary name/path. Defaults to "git" if empty.
	GitCommand string
	// ReposRoot is the root directory of main repositories.
	ReposRoot string
	// WorktreeRoot is the root directory where worktrees are located.
	WorktreeRoot string
	// DryRun controls whether worktree removal and prune run in dry-run mode.
	DryRun bool
	// Inner executes git commands. Defaults to ProcessRunner{} if nil.
	Inner Runner
}

WorktreePruneRunner prunes merged worktrees under WorktreeRoot for a repository and runs "git worktree prune".

func (*WorktreePruneRunner) Run added in v0.4.0

func (p *WorktreePruneRunner) Run(ctx context.Context, dir string, _ []string, stdout, stderr io.Writer) error

Run discovers worktrees for dir under WorktreeRoot, removes those merged into the repository's default branch, and runs "git worktree prune".

Jump to

Keyboard shortcuts

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