Documentation
¶
Overview ¶
Package testutil provides helpers for creating temporary git repositories for end-to-end testing.
Index ¶
- type TestRepo
- func (r *TestRepo) AddCommit(message string) string
- func (r *TestRepo) Checkout(branch string)
- func (r *TestRepo) CreateAnnotatedTag(name, sha, message string)
- func (r *TestRepo) CreateBranch(name, sha string)
- func (r *TestRepo) CreateTag(name, sha string)
- func (r *TestRepo) HeadSha() string
- func (r *TestRepo) MergeCommit(message, otherSha string) string
- func (r *TestRepo) Path() string
- func (r *TestRepo) WriteConfig(content string)
- func (r *TestRepo) WriteConfigAt(relPath, content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestRepo ¶
type TestRepo struct {
// contains filtered or unexported fields
}
TestRepo is a builder for creating temporary git repositories with controlled commit history, tags, and branches for e2e testing.
func NewTestRepo ¶
NewTestRepo creates and initializes a new git repository in a temporary directory.
func (*TestRepo) AddCommit ¶
AddCommit creates a new commit with the given message. A file named after the commit index is created to ensure each commit has changes. Returns the commit SHA.
func (*TestRepo) CreateAnnotatedTag ¶
CreateAnnotatedTag creates an annotated tag pointing at the given SHA.
func (*TestRepo) CreateBranch ¶
CreateBranch creates a new branch pointing at the given SHA and checks it out.
func (*TestRepo) MergeCommit ¶
MergeCommit creates a merge commit with two parents: the current HEAD and the given SHA. Returns the merge commit SHA.
func (*TestRepo) WriteConfig ¶
WriteConfig writes a go-gitsemver.yml file in the repo root.
func (*TestRepo) WriteConfigAt ¶
WriteConfigAt writes a config file at a custom path relative to the repo root.