Documentation ¶
Index ¶
- Constants
- Variables
- func FakeCommit(t sktest.TestingT, msg, branch string, parents ...*vcsinfo.LongCommit) *vcsinfo.LongCommit
- func FakeCommitAt(t sktest.TestingT, msg, branch string, ts time.Time, ...) *vcsinfo.LongCommit
- func FillWithBranchingHistory(mg *MemGit) []string
- type MemGit
- func (g *MemGit) AddUpdater(u Updater)
- func (g *MemGit) CheckoutBranch(branch string)
- func (g *MemGit) Commit(msg string, parents ...string) string
- func (g *MemGit) CommitAt(msg string, ts time.Time, parents ...string) string
- func (g *MemGit) CommitN(n int) []string
- func (g *MemGit) Merge(branch string) string
- func (g *MemGit) NewBranch(branch, head string)
- type Updater
Constants ¶
const ( // These are the commit hashes generated by CommitN(2) when run as the // first call to MemGit. Commit0 = "407108ae8039ba9dce77e81057721fc7c4dbab87" Commit1 = "a1dcf4a9669ff77919dfca71901ec98145b0af94" )
Variables ¶
var ( // BaseTime is an arbitrary timestamp used as the time of the first // commit. Subsequent commits add a fixed duration to the timestamp // of their parent(s). This keeps the commit hashes predictable. BaseTime = time.Unix(1571926390, 0).UTC() )
Functions ¶
func FakeCommit ¶
func FakeCommit(t sktest.TestingT, msg, branch string, parents ...*vcsinfo.LongCommit) *vcsinfo.LongCommit
FakeCommit creates a LongCommit with the given message, belonging to the given branch, and with the given parent commits. Its Timestamp and Index increase monotonically with respect to the parents.
func FakeCommitAt ¶
func FakeCommitAt(t sktest.TestingT, msg, branch string, ts time.Time, parents ...*vcsinfo.LongCommit) *vcsinfo.LongCommit
FakeCommitAt creates a LongCommit with the given message at the given time, belonging to the given branch, and with the given parent commits. Its Index increases monotonically with respect to the parents.
func FillWithBranchingHistory ¶
FillWithBranchingHistory adds commits to the MemGit.
The repo layout looks like this:
older newer c0--c1------c3--c4--
\-c2-----/
Returns the commit hashes in order from c0-c4. This is analogous to git_builder.FillWithBranchingHistory.
Types ¶
type MemGit ¶
type MemGit struct {
// contains filtered or unexported fields
}
MemGit is a struct used for writing fake commits into a GitStore.
func (*MemGit) AddUpdater ¶
AddUpdater adds the given Updater to the MemGit. Subsequent mutations to the MemGit will result in a call to Updater.Update().
func (*MemGit) CheckoutBranch ¶
CheckoutBranch switches to the given branch.
func (*MemGit) Commit ¶
Commit adds a commit to the GitStore with the given commit message and parents, and returns its hash. If no parents are provided, the head of the current branch is used as the parent. In either case, the head of the current branch is set to be the new commit.
func (*MemGit) CommitAt ¶
CommitAt adds a commit to the GitStore with the given commit message, timestamp, and parents, and returns its hash. If no parents are provided, the head of the current branch is used as the parent. In either case, the head of the current branch is set to be the new commit.
func (*MemGit) CommitN ¶
CommitN adds N commits to the GitStore on the current branch and returns their hashes in reverse chronological order.