Documentation
¶
Overview ¶
Package 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.
The 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.
HOME is deliberately not in the transport set: a caller that isolates HOME and a caller that inherits it disagree, so each supplies it itself.
Index ¶
- func Command(ctx context.Context, git, dir string, args ...string) *exec.Cmd
- func Env(opts EnvOptions) []string
- func Output(ctx context.Context, git, dir string, args ...string) (string, error)
- func Resolve(path string) (string, error)
- func Run(ctx context.Context, git, dir string, args ...string) error
- type EnvOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Command ¶
Command 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; nothing else the host sets reaches the command.
func Env ¶
func Env(opts EnvOptions) []string
Env 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.
Types ¶
type EnvOptions ¶
type EnvOptions struct {
// Transport inherits the transport variables from the parent when set.
Transport bool
// Passthrough names further variables to inherit from the parent when set.
Passthrough []string
// Literal entries are appended last as "NAME=value", so they override any
// inherited value of the same name.
Literal []string
}
EnvOptions selects what, on top of the always-applied scrub set, a git command's environment carries.