testgit

package
v0.21.13 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testgit redirects git's config lookup inside test binaries so a subprocess git call can never read or write the developer's real ~/.gitconfig or /etc/gitconfig. Tests that commit without setting a repo-local identity fall back to the fixed sandbox identity below, and gpgsign is disabled so machines with commit signing don't prompt or fail.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure()

Configure points GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM at throwaway files containing a fixed test identity. Call it from a package TestMain before m.Run(); every git subprocess spawned by the test binary inherits the redirected config via os.Environ.

func Main

func Main(m *testing.M)

Main runs m.Run() under hermetic git configuration and removes the throwaway config directory afterwards. Use it as the whole TestMain in packages that do not already have one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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