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 ¶
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 ¶
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 ¶
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.
type Result ¶ added in v0.3.0
type Result struct {
Stdout, Stderr string
// Code is the exit code (-1 when the process did not exit normally).
Code int
}
Result is the outcome of Exec.