Documentation ¶
Index ¶
- func AddAuthorInfo(cmd *exec.Cmd, timestamp *time.Time)
- func CleanGitEnv() []string
- type TestRepo
- func (repo *TestRepo) AddFile(t *testing.T, relativePath, contents string)
- func (repo *TestRepo) Clone(t *testing.T, pattern string) *TestRepo
- func (repo *TestRepo) ConfigAdd(t *testing.T, key, value string)
- func (repo *TestRepo) CreateObject(t *testing.T, otype git.ObjectType, writer func(io.Writer) error) git.OID
- func (repo *TestRepo) CreateReferencedOrphan(t *testing.T, refname string)
- func (repo *TestRepo) GitCommand(t *testing.T, args ...string) *exec.Cmd
- func (repo *TestRepo) Init(t *testing.T, bare bool)
- func (repo *TestRepo) Remove(t *testing.T)
- func (repo *TestRepo) Repository(t *testing.T) *git.Repository
- func (repo *TestRepo) UpdateRef(t *testing.T, refname string, oid git.OID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAuthorInfo ¶
AddAuthorInfo adds environment variables to `cmd.Env` that set the Git author and committer to known values and set the timestamp to `*timestamp`. Then `*timestamp` is moved forward by a minute, so that each commit gets a unique timestamp.
func CleanGitEnv ¶
func CleanGitEnv() []string
CleanGitEnv returns a clean environment for running `git` commands so that they won't be affected by the local environment.
Types ¶
type TestRepo ¶
type TestRepo struct {
Path string
}
TestRepo represents a git repository used for tests.
func NewTestRepo ¶
NewTestRepo creates and initializes a test repository in a temporary directory constructed using `pattern`. The caller must delete the repository by calling `repo.Remove()`.
func (*TestRepo) AddFile ¶
AddFile adds and stages a file in `repo` at path `relativePath` with the specified `contents`. This must be run in a non-bare repository.
func (*TestRepo) Clone ¶
Clone creates a clone of `repo` at a temporary path constructued using `pattern`. The caller is responsible for removing it when done by calling `Remove()`.
func (*TestRepo) CreateObject ¶
func (repo *TestRepo) CreateObject( t *testing.T, otype git.ObjectType, writer func(io.Writer) error, ) git.OID
CreateObject creates a new Git object, of the specified type, in the repository at `repoPath`. `writer` is a function that generates the object contents in `git hash-object` input format.
func (*TestRepo) CreateReferencedOrphan ¶
CreateReferencedOrphan creates a simple new orphan commit and points the reference with name `refname` at it. This can be run in a bare or non-bare repository.
func (*TestRepo) GitCommand ¶
GitCommand creates an `*exec.Cmd` for running `git` in `repo` with the specified arguments.
func (*TestRepo) Repository ¶
func (repo *TestRepo) Repository(t *testing.T) *git.Repository
Repository returns a `*git.Repository` for `repo`.