gitxtest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 6 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 gitxtest builds throwaway git repositories for tests. Identity and dates are pinned through the environment, the user's and the system's git config are ignored, and nothing here touches the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	Dir string
	// contains filtered or unexported fields
}

Repo is a temporary repository.

func New

func New(t *testing.T) *Repo

New initialises an empty repository on branch main in a temporary directory. It points HOME and the global config at an empty directory for the whole test, so the code under test sees no user configuration either.

func (*Repo) Commit

func (r *Repo) Commit(msg, author string, when time.Time) string

Commit stages everything and commits with message msg by author at when. It returns the full commit id. A commit with no changes is allowed.

func (*Repo) Git

func (r *Repo) Git(args ...string) string

Git runs git in the repository with author and committer pinned to "Test Author" at the Unix epoch, and returns its trimmed stdout. It fails the test on error.

func (*Repo) GitAs

func (r *Repo) GitAs(name string, when time.Time, args ...string) string

GitAs is Git with the given author name (also the committer) and date.

func (*Repo) Remove

func (r *Repo) Remove(rel string)

Remove deletes the slash path rel from the working tree.

func (*Repo) Stage

func (r *Repo) Stage(rel string)

Stage stages the slash path rel.

func (*Repo) Write

func (r *Repo) Write(rel, content string)

Write writes content to the slash path rel in the working tree, creating directories.

Jump to

Keyboard shortcuts

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