temp_repo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChdirTempDir

func ChdirTempDir(t *testing.T) string

ChdirTempDir chdirs into a fresh temp dir for the duration of the test.

CAUTION: process cwd is shared, so a test that calls this cannot run in parallel with another test that also calls it (or runs git commands relying on cwd). Prefer passing dir explicitly where possible.

func CreateCommit

func CreateCommit(t testing.TB, dir, filename, content, message string)

CreateCommit writes a file then stages and commits it.

func InitEmptyTempRepo added in v0.7.0

func InitEmptyTempRepo(t *testing.T) string

InitEmptyTempRepo creates a temp git repo without any commits (no branches), chdirs into it, and returns the path. Like InitTempRepo but stops before the initial commit — useful for testing "no branches" error paths.

Same cwd-sharing caveat as InitTempRepo; cannot run in parallel.

func InitTempRepo

func InitTempRepo(t *testing.T) string

InitTempRepo creates a temp git repo, chdirs into it, makes an initial commit, and returns the repo path.

Uses ChdirTempDir under the hood, so tests using InitTempRepo cannot run in parallel. Use NewRepo for parallel-safe tests that pass dir explicitly.

func NewRepo

func NewRepo(t *testing.T) string

NewRepo creates a temp git repo without chdir-ing into it and returns its path. Safe to call from t.Parallel() tests.

func RunGit

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

RunGit runs a git command inside dir and returns its combined output.

func WriteFile

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

WriteFile writes content to dir/filename, failing the test on error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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