Documentation
¶
Index ¶
- type Repo
- func (r *Repo) AddRemote(name, url string)
- func (r *Repo) Checkout(ref string)
- func (r *Repo) Commit(msg string) string
- func (r *Repo) CreateBranch(name string)
- func (r *Repo) RunGit(args ...string) string
- func (r *Repo) SetRemoteHEAD(remote, branch string)
- func (r *Repo) TryGit(args ...string) (string, error)
- func (r *Repo) WriteFile(path, content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
Dir string // working tree
GitDir string // .git
// contains filtered or unexported fields
}
Repo is a temporary isolated git repository for integration tests.
func Attach ¶
Attach wraps an existing on-disk repository (e.g. a copy made by a test) in a Repo handle, without initializing anything.
func NewRepo ¶
NewRepo creates a fresh git repo in t.TempDir() with full isolation. The repo is initialised on branch "main" with one empty commit.
func (*Repo) AddRemote ¶
AddRemote adds a remote with the given name pointing to url (or another repo's Dir).
func (*Repo) Commit ¶
Commit stages all changes and creates a commit with msg. Returns the 40-character commit SHA.
func (*Repo) CreateBranch ¶
CreateBranch creates and checks out a new branch.
func (*Repo) RunGit ¶
RunGit executes `git <args...>` in the repo dir with isolation env. Returns combined stdout (trimmed). t.Fatal on non-zero exit.
func (*Repo) SetRemoteHEAD ¶
SetRemoteHEAD sets refs/remotes/<remote>/HEAD to a symbolic-ref for branch.