Help us shape the future of Go! Take the 2026 Go Developer Survey

testgit

package
v0.10.22 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testgit runs test Git commands without the caller's GIT_* variables. Test-only: never import it from production code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(tb testing.TB, dir string, args ...string) *exec.Cmd

Command builds a Git command rooted at dir. Hooks export GIT_DIR, GIT_INDEX_FILE and friends; cmd.Dir alone does not isolate a test repository. Keep non-Git environment variables and disable system Git configuration. Tests that commit must provide their own identity (local config or -c flags).

func Env added in v0.10.22

func Env() []string

Env returns the process environment with every GIT_* variable removed and GIT_CONFIG_NOSYSTEM=1 set.

func Run

func Run(tb testing.TB, dir string, args ...string) []byte

Run executes a Git command, returning its combined output and failing the calling test with that output if the command fails. Use Command for expected nonzero exits or when the command needs further customization.

func ShellCommand added in v0.10.22

func ShellCommand(tb testing.TB, dir, script string) *exec.Cmd

ShellCommand builds a bash -c command without the caller's GIT_* variables. Hooks export GIT_DIR, GIT_INDEX_FILE and friends; cmd.Dir alone does not isolate a test repository. An empty dir leaves cmd.Dir unset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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