gittest

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gittest creates isolated temporary repositories for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commit

func Commit(t testing.TB, dir, name, content, message string) string

Commit writes name with content and commits it on the current branch.

func InitRemote added in v0.1.4

func InitRemote(t testing.TB, dir string) string

InitRemote creates a bare clone of dir as its origin, pushes every branch and sets their upstreams. It returns the bare repository's path. Tests move the remote by committing on a detached HEAD and pushing to it.

func InitRepo

func InitRepo(t testing.TB) string

InitRepo creates a repository with one commit on main and returns its path. Call Isolate first.

func Isolate

func Isolate(t testing.TB)

Isolate points git (and anything else) at a throwaway HOME and global config so tests never read or write the developer's real configuration.

func Run

func Run(t testing.TB, dir string, args ...string) string

Run executes git in dir and fails the test on error. It returns trimmed stdout.

func WriteFile

func WriteFile(t testing.TB, dir, name, content string)

WriteFile writes a file under dir, creating parents.

Types

This section is empty.

Jump to

Keyboard shortcuts

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