Documentation
¶
Overview ¶
Package exec provides the shared subprocess-runner interface used by the rest of the codebase to invoke git, gh, and tmux without binding production call sites to os/exec directly. Tests inject fakes; production uses Default.
It also owns the constructors for every git and gh subprocess: GitCommand (forces only git's message language to C, so the English stderr callers match on is what git actually prints, while the user's character set and other locale categories reach the hooks and filters git spawns) and GhCommand (runs gh with prompts and the update notifier disabled). TestNoRawGitGhExec fails on any raw exec.Command("git"|"gh", …) in production code outside command.go. tmux has its own constructor, session/tmux.Command, enforced the same way.
Kept as a leaf package so every layer — cmd/, session/git/, tools/ — can import it without creating a cycle (cmd/ imports session/git/).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GhCommand ¶ added in v0.13.0
GhCommand builds a gh invocation bound to ctx. Every gh subprocess loom runs is built here (TestNoRawGitGhExec enforces it). loom's gh calls never have a terminal: GH_PROMPT_DISABLED=1 guarantees a would-be prompt fails fast instead of waiting out the deadline, and GH_NO_UPDATE_NOTIFIER=1 keeps the "new release available" check off the network and out of the captured output. gh already skips both without a TTY; the variables pin that rather than relying on gh's detection.
func GitCommand ¶ added in v0.13.0
GitCommand builds a git invocation bound to ctx. Every git subprocess loom runs is built here (TestNoRawGitGhExec enforces it) so its messages are untranslated: callers classify failures by matching git's English stderr (isBranchAbsentErr, isWorktreeAbsentErr, …) and parse its English output (parseShortStat's "insertion"/"deletion"), and a user's non-English locale would otherwise silently misclassify both. Only the message language is forced (see gitEnv); the character set, collation and every other locale category stay the user's, because hooks, filters and credential helpers that git spawns inherit this environment and some (Ruby hooks, for one) break under an ASCII LC_CTYPE.
A non-empty dir is passed as `git -C dir`; "" adds nothing and git runs in the process working directory (or c.Dir, if the caller sets one). The caller's args slice is never modified.
c.Env is always set. A caller that needs extra variables appends them (`c.Env = append(c.Env, "GIT_INDEX_FILE=…")`) rather than rebuilding from os.Environ(), which would drop the locale overrides.