6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 14:48:47 +00:00

Add missing docstrings

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-30 11:32:05 +02:00
parent 235ea0d811
commit 29330d8af7

View File

@@ -13,12 +13,13 @@ type Repo struct {
t *testing.T
}
// Path returs path to a repository.
func (r *Repo) Path() string {
return r.path
}
// 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() {
err := os.RemoveAll(r.path)
if err != nil {
@@ -26,6 +27,7 @@ func (r *Repo) cleanup() {
}
}
// RepoEmpty creates an empty git repo.
func RepoEmpty(t *testing.T) *Repo {
dir, err := io.TempDir()
checkFatal(t, err)
@@ -41,6 +43,7 @@ func RepoEmpty(t *testing.T) *Repo {
return r
}
// RepoWithUntracked creates a git repo with a single untracked file.
func RepoWithUntracked(t *testing.T) *Repo {
r := RepoEmpty(t)
r.writeFile("README.md", "I'm a readme file")
@@ -48,6 +51,7 @@ func RepoWithUntracked(t *testing.T) *Repo {
return r
}
// RepoWithStaged creates a git repo with a single staged file.
func RepoWithStaged(t *testing.T) *Repo {
r := RepoEmpty(t)
r.writeFile("README.md", "I'm a readme file")
@@ -56,6 +60,7 @@ func RepoWithStaged(t *testing.T) *Repo {
return r
}
// RepoWithCommit creates a git repo with a single commit.
func RepoWithCommit(t *testing.T) *Repo {
r := RepoEmpty(t)
r.writeFile("README.md", "I'm a readme file")
@@ -65,6 +70,7 @@ func RepoWithCommit(t *testing.T) *Repo {
return r
}
// RepoWithUncommittedAndUntracked creates a git repo with one staged but uncommitted file and one untracked file.
func RepoWithUncommittedAndUntracked(t *testing.T) *Repo {
r := RepoEmpty(t)
r.writeFile("README.md", "I'm a readme file")
@@ -76,6 +82,7 @@ func RepoWithUncommittedAndUntracked(t *testing.T) *Repo {
return r
}
// RepoWithBranch creates a git repo with a new branch.
func RepoWithBranch(t *testing.T) *Repo {
r := RepoWithCommit(t)
r.branch("feature/branch")
@@ -84,6 +91,7 @@ func RepoWithBranch(t *testing.T) *Repo {
return r
}
// RepoWithTag creates a git repo with a new tag.
func RepoWithTag(t *testing.T) *Repo {
r := RepoWithCommit(t)
r.tag("v0.0.1")
@@ -92,6 +100,7 @@ func RepoWithTag(t *testing.T) *Repo {
return r
}
// RepoWithBranchWithUpstream creates a git repo by cloning another repo and checking out a remote branch.
func RepoWithBranchWithUpstream(t *testing.T) *Repo {
origin := RepoWithCommit(t)
origin.branch("feature/branch")
@@ -101,6 +110,7 @@ func RepoWithBranchWithUpstream(t *testing.T) *Repo {
return r
}
// RepoWithBranchWithoutUpstream creates a git repo by cloning another repo and checking out a new local branch.
func RepoWithBranchWithoutUpstream(t *testing.T) *Repo {
origin := RepoWithCommit(t)
@@ -110,6 +120,7 @@ func RepoWithBranchWithoutUpstream(t *testing.T) *Repo {
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 {
origin := RepoWithCommit(t)
origin.branch("feature/branch")
@@ -124,6 +135,7 @@ func RepoWithBranchAhead(t *testing.T) *Repo {
return r
}
// RepoWithBranchBehind creates a git repo with a branch being behind a remote branch by 1 commit.
func RepoWithBranchBehind(t *testing.T) *Repo {
origin := RepoWithCommit(t)
origin.branch("feature/branch")
@@ -141,7 +153,7 @@ func RepoWithBranchBehind(t *testing.T) *Repo {
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 {
origin := RepoWithCommit(t)
origin.branch("feature/branch")