Documentation ¶
Index ¶
- func GitSetup(ctx context.Context, g *GitBuilder) []string
- type GitBuilder
- func (g *GitBuilder) AcceptPushes(ctx context.Context)
- func (g *GitBuilder) Add(ctx context.Context, file, contents string)
- func (g *GitBuilder) AddGen(ctx context.Context, file string)
- func (g *GitBuilder) CheckoutBranch(ctx context.Context, name string)
- func (g *GitBuilder) Cleanup()
- func (g *GitBuilder) Commit(ctx context.Context) string
- func (g *GitBuilder) CommitGen(ctx context.Context, file string) string
- func (g *GitBuilder) CommitGenAt(ctx context.Context, file string, ts time.Time) string
- func (g *GitBuilder) CommitGenMsg(ctx context.Context, file, msg string) string
- func (g *GitBuilder) CommitMsg(ctx context.Context, msg string) string
- func (g *GitBuilder) CommitMsgAt(ctx context.Context, msg string, time time.Time) string
- func (g *GitBuilder) CreateBranchAtCommit(ctx context.Context, name, commit string)
- func (g *GitBuilder) CreateBranchTrackBranch(ctx context.Context, newBranch, existingBranch string)
- func (g *GitBuilder) CreateFakeGerritCLGen(ctx context.Context, issue, patchset string)
- func (g *GitBuilder) CreateOrphanBranch(ctx context.Context, newBranch string)
- func (g *GitBuilder) Dir() string
- func (g *GitBuilder) Git(ctx context.Context, cmd ...string) string
- func (g *GitBuilder) MergeBranch(ctx context.Context, name string) string
- func (g *GitBuilder) MergeBranchAt(ctx context.Context, name string, ts time.Time) string
- func (g *GitBuilder) RepoUrl() string
- func (g *GitBuilder) Reset(ctx context.Context, args ...string)
- func (g *GitBuilder) Seed(seed int64)
- func (g *GitBuilder) UpdateRef(ctx context.Context, args ...string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GitBuilder ¶
type GitBuilder struct {
// contains filtered or unexported fields
}
GitBuilder creates commits and branches in a git repo.
func GitInit ¶
func GitInit(t sktest.TestingT, ctx context.Context) *GitBuilder
GitInit calls GitInitWithDefaultBranch with MainBranch.
func GitInitWithDefaultBranch ¶
func GitInitWithDefaultBranch(t sktest.TestingT, ctx context.Context, defaultBranch string) *GitBuilder
GitInitWithDefaultBranch creates a new git repo in a temporary directory with the specified default branch and returns a GitBuilder to manage it. Call Cleanup to remove the temporary directory. The current branch will be the main branch.
func GitInitWithDir ¶
GitInit creates a new git repo in the specified directory and returns a GitBuilder to manage it. Call Cleanup to remove the temporary directory. The current branch will be the main branch.
func (*GitBuilder) AcceptPushes ¶
func (g *GitBuilder) AcceptPushes(ctx context.Context)
AcceptPushes allows pushing changes to the repo.
func (*GitBuilder) Add ¶
func (g *GitBuilder) Add(ctx context.Context, file, contents string)
Add writes contents to file and adds it to the index.
func (*GitBuilder) AddGen ¶
func (g *GitBuilder) AddGen(ctx context.Context, file string)
AddGen writes arbitrary content to file and adds it to the index.
func (*GitBuilder) CheckoutBranch ¶
func (g *GitBuilder) CheckoutBranch(ctx context.Context, name string)
CheckoutBranch checks out the given branch.
func (*GitBuilder) Cleanup ¶
func (g *GitBuilder) Cleanup()
Cleanup removes the directory containing the git repo.
func (*GitBuilder) Commit ¶
func (g *GitBuilder) Commit(ctx context.Context) string
Commit commits files in the index. The current branch is then pushed. Uses an arbitrary commit message. Returns the hash of the new commit.
func (*GitBuilder) CommitGen ¶
func (g *GitBuilder) CommitGen(ctx context.Context, file string) string
CommitGen commits arbitrary content to the given file. The current branch is then pushed. Returns the hash of the new commit.
func (*GitBuilder) CommitGenAt ¶
CommitGenAt commits arbitrary content to the given file using the given time as the commit time. Note that the nanosecond component of time will be dropped. Returns the hash of the new commit.
func (*GitBuilder) CommitGenMsg ¶
func (g *GitBuilder) CommitGenMsg(ctx context.Context, file, msg string) string
CommitGenMsg commits arbitrary content to the given file and uses the given commit message. The current branch is then pushed. Returns the hash of the new commit.
func (*GitBuilder) CommitMsg ¶
func (g *GitBuilder) CommitMsg(ctx context.Context, msg string) string
CommitMsg commits files in the index with the given commit message. The current branch is then pushed. Returns the hash of the new commit.
func (*GitBuilder) CommitMsgAt ¶
CommitMsg commits files in the index with the given commit message using the given time as the commit time. The current branch is then pushed. Note that the nanosecond component of time will be dropped. Returns the hash of the new commit.
func (*GitBuilder) CreateBranchAtCommit ¶
func (g *GitBuilder) CreateBranchAtCommit(ctx context.Context, name, commit string)
CreateBranchTrackBranch creates a new branch pointing at the given commit, checks out the new branch, and pushes the new branch.
func (*GitBuilder) CreateBranchTrackBranch ¶
func (g *GitBuilder) CreateBranchTrackBranch(ctx context.Context, newBranch, existingBranch string)
CreateBranchTrackBranch creates a new branch tracking an existing branch, checks out the new branch, and pushes the new branch.
func (*GitBuilder) CreateFakeGerritCLGen ¶
func (g *GitBuilder) CreateFakeGerritCLGen(ctx context.Context, issue, patchset string)
CreateFakeGerritCLGen creates a Gerrit-like ref so that it can be applied like a CL on a trybot.
func (*GitBuilder) CreateOrphanBranch ¶
func (g *GitBuilder) CreateOrphanBranch(ctx context.Context, newBranch string)
CreateOrphanBranch creates a new orphan branch.
func (*GitBuilder) Dir ¶
func (g *GitBuilder) Dir() string
Dir returns the directory of the git repo, e.g. for cloning.
func (*GitBuilder) MergeBranch ¶
func (g *GitBuilder) MergeBranch(ctx context.Context, name string) string
MergeBranch merges the given branch into the current branch and pushes the current branch. Returns the hash of the new commit.
func (*GitBuilder) MergeBranchAt ¶
MergeBranchAt merges the given branch into the current branch at the given time and pushes the current branch. Returns the hash of the new commit.
func (*GitBuilder) RepoUrl ¶
func (g *GitBuilder) RepoUrl() string
RepoUrl returns a git-friendly URL for the repo.
func (*GitBuilder) Reset ¶
func (g *GitBuilder) Reset(ctx context.Context, args ...string)
Reset runs "git reset" in the repo.
func (*GitBuilder) Seed ¶
func (g *GitBuilder) Seed(seed int64)
Seed replaces the random seed used by the GitBuilder.