Documentation
¶
Overview ¶
Package exec runs subprocesses. Every subprocess git-stack starts goes through a Runner so that output capture, TTY hand-off, cancellation and debug logging are handled in exactly one place.
Capture mode is the default: stdout and stderr are buffered and stdin is whatever the caller supplies (never the parent's stdin). Passthrough mode attaches the real terminal and is only available to runners built with WithTTY; the MCP server never constructs such a runner.
A runner without a TTY also keeps its children away from the terminal the process happens to have been started from: they run in their own session (no controlling terminal, so /dev/tty cannot be opened), git's terminal prompts are disabled and GPG_TTY is dropped. Otherwise a passphrase or credential prompt from ssh-keygen, gpg or git would wait on a terminal nobody is watching, which is how the MCP server used to hang.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrTTYUnavailable is returned when Passthrough mode is requested from a runner that has no terminal attached.
Functions ¶
Types ¶
type Cmd ¶
type Cmd struct {
Name string
Args []string
// Dir is the working directory; empty means the current directory.
Dir string
// Env holds KEY=VALUE pairs appended to the parent environment.
Env []string
// Unset lists environment keys removed before Env is applied.
Unset []string
// Stdin is fed to the process in Capture mode. Nil means no input.
Stdin io.Reader
// Stream, when set in Capture mode, also receives the process's stderr as
// it is produced so progress from a long backend command can be relayed
// live. Stderr is still captured in the Result. Ignored in Passthrough.
Stream io.Writer
Mode Mode
}
Cmd describes a subprocess to run.
type NotFoundError ¶
type NotFoundError struct {
Name string
}
NotFoundError reports that the executable is not on PATH.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Option ¶
type Option func(*runner)
Option configures a Runner.
type Result ¶
Result is the outcome of a finished subprocess.
type Runner ¶
type Runner interface {
// Run executes c and waits for it. A non-zero exit status is returned as
// *ExitError (the Result is still populated). A missing executable is
// returned as *NotFoundError. Context cancellation is returned as the
// context's error.
Run(ctx context.Context, c Cmd) (Result, error)
}
Runner runs subprocesses.