mirror of
https://github.com/grdl/git-get.git
synced 2026-02-09 12:04:15 +00:00
Add missing docstrings
This commit is contained in:
@@ -13,12 +13,13 @@ type Repo struct {
|
|||||||
t *testing.T
|
t *testing.T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Path returs path to a repository.
|
||||||
func (r *Repo) Path() string {
|
func (r *Repo) Path() string {
|
||||||
return r.path
|
return r.path
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this should be a method of a tempDir, not a repo
|
// TODO: this should be a method of a tempDir, not a repo
|
||||||
// Automatically remove test repo when the test is over
|
// Automatically remove test repo when the test is over.
|
||||||
func (r *Repo) cleanup() {
|
func (r *Repo) cleanup() {
|
||||||
err := os.RemoveAll(r.path)
|
err := os.RemoveAll(r.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -26,6 +27,7 @@ func (r *Repo) cleanup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoEmpty creates an empty git repo.
|
||||||
func RepoEmpty(t *testing.T) *Repo {
|
func RepoEmpty(t *testing.T) *Repo {
|
||||||
dir, err := io.TempDir()
|
dir, err := io.TempDir()
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
@@ -41,6 +43,7 @@ func RepoEmpty(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithUntracked creates a git repo with a single untracked file.
|
||||||
func RepoWithUntracked(t *testing.T) *Repo {
|
func RepoWithUntracked(t *testing.T) *Repo {
|
||||||
r := RepoEmpty(t)
|
r := RepoEmpty(t)
|
||||||
r.writeFile("README.md", "I'm a readme file")
|
r.writeFile("README.md", "I'm a readme file")
|
||||||
@@ -48,6 +51,7 @@ func RepoWithUntracked(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithStaged creates a git repo with a single staged file.
|
||||||
func RepoWithStaged(t *testing.T) *Repo {
|
func RepoWithStaged(t *testing.T) *Repo {
|
||||||
r := RepoEmpty(t)
|
r := RepoEmpty(t)
|
||||||
r.writeFile("README.md", "I'm a readme file")
|
r.writeFile("README.md", "I'm a readme file")
|
||||||
@@ -56,6 +60,7 @@ func RepoWithStaged(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithCommit creates a git repo with a single commit.
|
||||||
func RepoWithCommit(t *testing.T) *Repo {
|
func RepoWithCommit(t *testing.T) *Repo {
|
||||||
r := RepoEmpty(t)
|
r := RepoEmpty(t)
|
||||||
r.writeFile("README.md", "I'm a readme file")
|
r.writeFile("README.md", "I'm a readme file")
|
||||||
@@ -65,6 +70,7 @@ func RepoWithCommit(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithUncommittedAndUntracked creates a git repo with one staged but uncommitted file and one untracked file.
|
||||||
func RepoWithUncommittedAndUntracked(t *testing.T) *Repo {
|
func RepoWithUncommittedAndUntracked(t *testing.T) *Repo {
|
||||||
r := RepoEmpty(t)
|
r := RepoEmpty(t)
|
||||||
r.writeFile("README.md", "I'm a readme file")
|
r.writeFile("README.md", "I'm a readme file")
|
||||||
@@ -76,6 +82,7 @@ func RepoWithUncommittedAndUntracked(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithBranch creates a git repo with a new branch.
|
||||||
func RepoWithBranch(t *testing.T) *Repo {
|
func RepoWithBranch(t *testing.T) *Repo {
|
||||||
r := RepoWithCommit(t)
|
r := RepoWithCommit(t)
|
||||||
r.branch("feature/branch")
|
r.branch("feature/branch")
|
||||||
@@ -84,6 +91,7 @@ func RepoWithBranch(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithTag creates a git repo with a new tag.
|
||||||
func RepoWithTag(t *testing.T) *Repo {
|
func RepoWithTag(t *testing.T) *Repo {
|
||||||
r := RepoWithCommit(t)
|
r := RepoWithCommit(t)
|
||||||
r.tag("v0.0.1")
|
r.tag("v0.0.1")
|
||||||
@@ -92,6 +100,7 @@ func RepoWithTag(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithBranchWithUpstream creates a git repo by cloning another repo and checking out a remote branch.
|
||||||
func RepoWithBranchWithUpstream(t *testing.T) *Repo {
|
func RepoWithBranchWithUpstream(t *testing.T) *Repo {
|
||||||
origin := RepoWithCommit(t)
|
origin := RepoWithCommit(t)
|
||||||
origin.branch("feature/branch")
|
origin.branch("feature/branch")
|
||||||
@@ -101,6 +110,7 @@ func RepoWithBranchWithUpstream(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithBranchWithoutUpstream creates a git repo by cloning another repo and checking out a new local branch.
|
||||||
func RepoWithBranchWithoutUpstream(t *testing.T) *Repo {
|
func RepoWithBranchWithoutUpstream(t *testing.T) *Repo {
|
||||||
origin := RepoWithCommit(t)
|
origin := RepoWithCommit(t)
|
||||||
|
|
||||||
@@ -110,6 +120,7 @@ func RepoWithBranchWithoutUpstream(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithBranchAhead creates a git repo with a branch being ahead of a remote branch by 1 commit.
|
||||||
func RepoWithBranchAhead(t *testing.T) *Repo {
|
func RepoWithBranchAhead(t *testing.T) *Repo {
|
||||||
origin := RepoWithCommit(t)
|
origin := RepoWithCommit(t)
|
||||||
origin.branch("feature/branch")
|
origin.branch("feature/branch")
|
||||||
@@ -124,6 +135,7 @@ func RepoWithBranchAhead(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoWithBranchBehind creates a git repo with a branch being behind a remote branch by 1 commit.
|
||||||
func RepoWithBranchBehind(t *testing.T) *Repo {
|
func RepoWithBranchBehind(t *testing.T) *Repo {
|
||||||
origin := RepoWithCommit(t)
|
origin := RepoWithCommit(t)
|
||||||
origin.branch("feature/branch")
|
origin.branch("feature/branch")
|
||||||
@@ -141,7 +153,7 @@ func RepoWithBranchBehind(t *testing.T) *Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a repo with 2 commits ahead and 1 behind
|
// RepoWithBranchAheadAndBehind creates a git repo with a branch being 2 commits ahead and 1 behind a remote branch.
|
||||||
func RepoWithBranchAheadAndBehind(t *testing.T) *Repo {
|
func RepoWithBranchAheadAndBehind(t *testing.T) *Repo {
|
||||||
origin := RepoWithCommit(t)
|
origin := RepoWithCommit(t)
|
||||||
origin.branch("feature/branch")
|
origin.branch("feature/branch")
|
||||||
|
|||||||
Reference in New Issue
Block a user