gitworkspace

package
v0.3.0-20261007172111-... Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gitworkspace defines the pluggable interface for executing git commands in a stateful workspace. The OSS implementation runs commands as local subprocesses; alternative deployments wrap their backend's exec API in the same contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandFailure

func CommandFailure(ctx context.Context, cmd Command, out Output) error

CommandFailure builds the error for a command that exited non-zero, in the form the git error classifier recognises. The diagnostic keeps all of stderr and stdout, since a classifying fragment can sit behind advice text. An ended ctx takes precedence, so a command killed by cancellation reads as cancellation rather than as a git failure.

Types

type Command

type Command struct {
	// Alias identifies this command's Output in the response. It must be unique
	// within one Exec batch.
	Alias string
	// Bin is the executable name, such as "git". The backend decides which
	// binary it resolves to.
	Bin string
	// Args are the command-line arguments. For git, Args[0] is the subcommand;
	// global options and identity belong to the backend, not here.
	Args []string
	// Stdin is optional standard input.
	Stdin string
}

Command is one command to execute in a git workspace.

type Factory

type Factory interface {
	// For returns a Workspace for the given repository. Cancelling ctx aborts
	// any running command and ends the Workspace, so ctx bounds its lifetime.
	For(ctx context.Context, repo string) (Workspace, error)
}

Factory creates Workspace instances bound to a repository.

type Output

type Output struct {
	// Alias matches the Command that produced this output.
	Alias string
	// ExitCode is the process exit code. It is unspecified when Skipped is set.
	ExitCode int32
	// Skipped reports that the command did not run because an earlier command
	// in the same batch failed.
	Skipped bool
	// Stdout is the captured standard output.
	Stdout string
	// Stderr is the captured standard error.
	Stderr string
}

Output is the result of one executed command.

type Workspace

type Workspace interface {
	// Exec runs a batch and returns one Output per command, in order. A
	// command that exits non-zero is reported in its Output, not as an error;
	// the error is reserved for failing to run the batch at all.
	Exec(commands []Command) ([]Output, error)
	// Close releases the workspace and its resources.
	Close() error
}

Workspace is a stateful git environment where command batches execute sequentially. Commands within one Exec call run in order; after the first non-zero exit, every remaining command is reported Skipped. State persists across Exec calls on the same Workspace. A Workspace is used by one goroutine at a time.

Directories

Path Synopsis
Package local implements gitworkspace.Workspace by executing commands as local subprocesses against a git clone on disk.
Package local implements gitworkspace.Workspace by executing commands as local subprocesses against a git clone on disk.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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