gitexec

package
v0.3.0-20260820034428-... Latest Latest
Warning

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

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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(ctx context.Context, git, dir string, args ...string) *exec.Cmd

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.

func Output

func Output(ctx context.Context, git, dir string, args ...string) (string, error)

Output executes a git command and returns its trimmed stdout.

func Resolve

func Resolve(path string) (string, error)

Resolve returns an absolute path to a git binary.

Preference 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.

func Run

func Run(ctx context.Context, git, dir string, args ...string) error

Run 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.

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.

Jump to

Keyboard shortcuts

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