{"modulePath":"github.com/uber/submitqueue","version":"v0.3.0-20261125210437-add1a4bd2ea2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gitexec\n\nPackage gitexec locates a git binary and composes the environment git runs in. It is the single source of truth for that environment across every SubmitQueue caller — demo tooling, the change provider's repository, and the Runway merger.\n\nThe environment has two halves. The scrub set denies git all ambient configuration that could change what a command produces — a global hooks path, a signing requirement, a commit template — which is what makes a scripted run behave the same on every machine. The transport set carries what a command needs to reach a remote — the SSH agent socket, git's ssh and credential helpers on PATH, TLS roots, proxy settings — none of which can change an answer. Every caller shares both halves; they differ only in the literal entries they add (a pinned exec path, an isolated HOME), which is why Env takes those as options rather than baking one caller's policy in.\n\nHOME is deliberately not in the transport set: a caller that isolates HOME and a caller that inherits it disagree, so each supplies it itself.\n\n## Functions\n\n```go\nfunc Command(ctx context.Context, git, dir string, args ...string) *exec.Cmd\n```\nCommand builds a git invocation in dir with the ambient environment removed. An empty dir runs in the current working directory. PATH is passed so git can find its helpers, with git's own directory first; nothing else the host sets reaches the command.\n\n```go\nfunc CommandFailure(ctx context.Context, args []string, message string, cause error) error\n```\nCommandFailure builds the error for a failed git invocation.\n\nA context that has ended takes precedence over whatever git reported. When os/exec kills a child because its context was cancelled, Wait reports only the death — a bare \\*exec.ExitError reading \"signal: killed\" — and neither context.Canceled nor context.DeadlineExceeded appears anywhere in the chain, so nothing downstream can tell an interrupted command apart from one that genuinely failed. Reading ctx.Err() here is the only place that distinction still exists; surfacing it puts cancellation back in the chain where the generic classifier can recognise it.\n\n```go\nfunc Env(opts EnvOptions) []string\n```\nEnv composes a git command environment: the scrub set, then the requested variables inherited from the parent (only those actually set, so an unset SSH\\_AUTH\\_SOCK stays absent rather than becoming empty), then the literals.\n\n```go\nfunc Operation(args []string) string\n```\nOperation returns the Git subcommand in args, or \"\" when args is empty.\n\n```go\nfunc Output(ctx context.Context, git, dir string, args ...string) (string, error)\n```\nOutput executes a git command and returns its trimmed stdout.\n\n```go\nfunc PathWithGitFirst(git string) string\n```\nPathWithGitFirst returns PATH with the directory of git in front, for a command that builds its own environment instead of using Command. Git runs some of its own commands by name, such as upload-pack and maintenance, and a git built without a usable exec path finds them on PATH. Without this, a newer pinned git can end up running an older one found elsewhere on PATH, which fails on options it does not know. A git given without a directory is found through PATH already, so it is left alone.\n\n```go\nfunc Resolve(path string) (string, error)\n```\nResolve returns an absolute path to a git binary.\n\nPreference order is the supplied path, then GIT\\_EXECUTABLE, then PATH — the same convention the Runway server's runtime resolution follows, so a deployment or a Bazel target can pin git without the caller knowing which did.\n\n```go\nfunc Run(ctx context.Context, git, dir string, args ...string) error\n```\nRun executes a git command and discards its output, reporting stderr in the error so a failure says what git said rather than only that it exited.\n\n## Types\n\n```go\ntype CommandError struct {\n\t// contains filtered or unexported fields\n}\n```\nCommandError preserves the failed Git operation and its process error for backend-specific classification after callers add contextual wrapping.\n\n```go\nfunc NewCommandError(operation, message string, cause error) *CommandError\n```\nNewCommandError records a failed Git operation without assigning retry policy. Callers supply the rendered diagnostic they want Error to expose.\n\n```go\nfunc (e *CommandError) Diagnostic() string\n```\nDiagnostic returns Git's rendered failure output.\n\n```go\nfunc (e *CommandError) Error() string\n```\nError returns the command diagnostic supplied by the execution boundary.\n\n```go\nfunc (e *CommandError) Operation() string\n```\nOperation returns the Git subcommand, such as fetch or cherry-pick.\n\n```go\nfunc (e *CommandError) Unwrap() error\n```\nUnwrap returns the process error reported by os/exec.\n\n```go\ntype EnvOptions struct {\n\t// Transport inherits the transport variables from the parent when set.\n\tTransport bool\n\t// Passthrough names further variables to inherit from the parent when set.\n\tPassthrough []string\n\t// Literal entries are appended last as \"NAME=value\", so they override any\n\t// inherited value of the same name.\n\tLiteral []string\n}\n```\nEnvOptions selects what, on top of the always-applied scrub set, a git command's environment carries.\n\n","path":"github.com/uber/submitqueue/platform/git/exec","name":"gitexec","synopsis":"Package gitexec locates a git binary and composes the environment git runs in.","isRedistributable":true}
