Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-27 07:35:13 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-27 07:35:13 +0300
commit81786f3bfc58fbe460ed285cbd745206802abe7e (patch)
tree2988c36b3ca7285ec5f47c4386131dc04f2362fc
parentdbac851fdbba25db9fc812de64d4af3f14cb28ad (diff)
parente67dcc3f6f26a8c8bd472ed756a235062f965d13 (diff)
Merge branch 'pks-gittest-hash-clean' into 'master'
gittest: Refactorings to make the package hash-clean See merge request gitlab-org/gitaly!4734
-rw-r--r--cmd/gitaly-git2go-v15/cherry_pick_test.go3
-rw-r--r--cmd/gitaly-git2go-v15/conflicts_test.go4
-rw-r--r--cmd/gitaly-git2go-v15/merge_test.go6
-rw-r--r--cmd/gitaly-git2go-v15/rebase_test.go2
-rw-r--r--cmd/gitaly-git2go-v15/revert_test.go10
-rw-r--r--cmd/gitaly-git2go-v15/testhelper_test.go7
-rw-r--r--internal/backup/backup_test.go1
-rw-r--r--internal/git/catfile/object_info_reader_test.go2
-rw-r--r--internal/git/gitpipe/catfile_info_test.go2
-rw-r--r--internal/git/gittest/command_test.go2
-rw-r--r--internal/git/gittest/commit.go39
-rw-r--r--internal/git/gittest/commit_test.go104
-rw-r--r--internal/git/gittest/delta_islands.go3
-rw-r--r--internal/git/gittest/intercepting_command_factory_test.go2
-rw-r--r--internal/git/gittest/objects.go5
-rw-r--r--internal/git/gittest/ref_test.go9
-rw-r--r--internal/git/gittest/repo.go8
-rw-r--r--internal/git/gittest/repository_suite.go10
-rw-r--r--internal/git/gittest/tag.go7
-rw-r--r--internal/git/gittest/testhelper_test.go4
-rw-r--r--internal/git/gittest/tree.go9
-rw-r--r--internal/git/gittest/tree_test.go20
-rw-r--r--internal/git/housekeeping/objects_test.go2
-rw-r--r--internal/git/housekeeping/optimize_repository_test.go18
-rw-r--r--internal/git/localrepo/repo_test.go10
-rw-r--r--internal/git/object_id.go24
-rw-r--r--internal/git/object_id_test.go33
-rw-r--r--internal/git/objectpool/fetch_test.go3
-rw-r--r--internal/git/stats/profile_test.go1
-rw-r--r--internal/git/testhelper_test.go (renamed from internal/git/helper_test.go)0
-rw-r--r--internal/gitaly/linguist/linguist_test.go2
-rw-r--r--internal/gitaly/service/commit/check_objects_exist_test.go2
-rw-r--r--internal/gitaly/service/commit/find_commit_test.go8
-rw-r--r--internal/gitaly/service/commit/list_all_commits_test.go9
-rw-r--r--internal/gitaly/service/commit/list_last_commits_for_tree_test.go2
-rw-r--r--internal/gitaly/service/commit/tree_entries_test.go4
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go2
-rw-r--r--internal/gitaly/service/diff/raw_test.go13
-rw-r--r--internal/gitaly/service/operations/branches_test.go2
-rw-r--r--internal/gitaly/service/operations/rebase_test.go9
-rw-r--r--internal/gitaly/service/operations/squash_test.go8
-rw-r--r--internal/gitaly/service/ref/find_all_tags_test.go58
-rw-r--r--internal/gitaly/service/ref/list_refs_test.go2
-rw-r--r--internal/gitaly/service/ref/refs_test.go30
-rw-r--r--internal/gitaly/service/ref/tag_signatures_test.go7
-rw-r--r--internal/gitaly/service/repository/create_fork_test.go2
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go4
-rw-r--r--internal/gitaly/service/repository/gc_test.go2
-rw-r--r--internal/gitaly/service/repository/license_test.go2
-rw-r--r--internal/gitaly/service/repository/optimize_test.go1
-rw-r--r--internal/gitaly/service/repository/prune_unreachable_objects_test.go14
-rw-r--r--internal/gitaly/service/repository/rename_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/upload_pack_test.go1
-rw-r--r--internal/gitaly/service/wiki/find_page_test.go1
54 files changed, 256 insertions, 281 deletions
diff --git a/cmd/gitaly-git2go-v15/cherry_pick_test.go b/cmd/gitaly-git2go-v15/cherry_pick_test.go
index e9b82c8db..129476451 100644
--- a/cmd/gitaly-git2go-v15/cherry_pick_test.go
+++ b/cmd/gitaly-git2go-v15/cherry_pick_test.go
@@ -148,7 +148,7 @@ func TestCherryPick(t *testing.T) {
testcfg.BuildGitalyGit2Go(t, cfg)
executor := buildExecutor(t, cfg)
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(tc.base...))
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(tc.base...))
ours, commit := "nonexistent", "nonexistent"
if len(tc.ours) > 0 {
@@ -229,7 +229,6 @@ func TestCherryPickStructuredErrors(t *testing.T) {
t,
cfg,
repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(gittest.TreeEntry{
Path: "file", Content: "foo", Mode: "100644",
}))
diff --git a/cmd/gitaly-git2go-v15/conflicts_test.go b/cmd/gitaly-git2go-v15/conflicts_test.go
index 4ab3e4de3..c8e9848eb 100644
--- a/cmd/gitaly-git2go-v15/conflicts_test.go
+++ b/cmd/gitaly-git2go-v15/conflicts_test.go
@@ -172,7 +172,7 @@ func TestConflicts(t *testing.T) {
testcfg.BuildGitalyGit2Go(t, cfg)
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(tc.base...))
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(tc.base...))
ours := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(tc.ours...))
theirs := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(tc.theirs...))
@@ -193,7 +193,7 @@ func TestConflicts(t *testing.T) {
func TestConflicts_checkError(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries())
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries())
validOID := glgit.ObjectID(base.String())
executor := buildExecutor(t, cfg)
diff --git a/cmd/gitaly-git2go-v15/merge_test.go b/cmd/gitaly-git2go-v15/merge_test.go
index 9f1919464..00c3b0ee3 100644
--- a/cmd/gitaly-git2go-v15/merge_test.go
+++ b/cmd/gitaly-git2go-v15/merge_test.go
@@ -289,7 +289,7 @@ func TestMerge_trees(t *testing.T) {
testcfg.BuildGitalyGit2Go(t, cfg)
executor := buildExecutor(t, cfg)
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(tc.base...))
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(tc.base...))
ours := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(tc.ours...))
theirs := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(tc.theirs...))
@@ -362,7 +362,7 @@ func TestMerge_squash(t *testing.T) {
theirFile1 := gittest.TreeEntry{Path: "file.txt", Content: "b\nc\nd", Mode: "100644"}
theirFile2 := gittest.TreeEntry{Path: "file.txt", Content: "b\nc\nd\ne", Mode: "100644"}
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(baseFile))
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(baseFile))
ours := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(ourFile))
theirs1 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(theirFile1))
theirs2 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(theirs1), gittest.WithTreeEntries(theirFile2))
@@ -420,7 +420,7 @@ func TestMerge_recursive(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "base", Content: "base\n", Mode: "100644"},
))
diff --git a/cmd/gitaly-git2go-v15/rebase_test.go b/cmd/gitaly-git2go-v15/rebase_test.go
index d6cce487b..38de7af42 100644
--- a/cmd/gitaly-git2go-v15/rebase_test.go
+++ b/cmd/gitaly-git2go-v15/rebase_test.go
@@ -246,7 +246,7 @@ func TestRebase_skipEmptyCommit(t *testing.T) {
// Set up history with two diverging lines of branches, where both sides have implemented
// the same changes. During rebase, the diff will thus become empty.
base := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(), gittest.WithTreeEntries(gittest.TreeEntry{
+ gittest.WithTreeEntries(gittest.TreeEntry{
Path: "a", Content: "base", Mode: "100644",
}),
)
diff --git a/cmd/gitaly-git2go-v15/revert_test.go b/cmd/gitaly-git2go-v15/revert_test.go
index 4b885c0e8..35a603ba9 100644
--- a/cmd/gitaly-git2go-v15/revert_test.go
+++ b/cmd/gitaly-git2go-v15/revert_test.go
@@ -86,7 +86,7 @@ func TestRevert_trees(t *testing.T) {
{
desc: "trivial revert succeeds",
setupRepo: func(t testing.TB, cfg config.Cfg, repoPath string) (ours, revert string) {
- baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "apple", Mode: "100644"},
gittest.TreeEntry{Path: "b", Content: "banana", Mode: "100644"},
))
@@ -113,7 +113,7 @@ func TestRevert_trees(t *testing.T) {
{
desc: "conflicting revert fails",
setupRepo: func(t testing.TB, cfg config.Cfg, repoPath string) (ours, revert string) {
- baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "apple", Mode: "100644"},
))
revertOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(baseOid), gittest.WithTreeEntries(
@@ -131,7 +131,7 @@ func TestRevert_trees(t *testing.T) {
{
desc: "empty revert fails",
setupRepo: func(t testing.TB, cfg config.Cfg, repoPath string) (ours, revert string) {
- baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ baseOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "apple", Mode: "100644"},
))
revertOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(baseOid), gittest.WithTreeEntries(
@@ -149,7 +149,7 @@ func TestRevert_trees(t *testing.T) {
{
desc: "nonexistent ours fails",
setupRepo: func(t testing.TB, cfg config.Cfg, repoPath string) (ours, revert string) {
- revertOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ revertOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "apple", Mode: "100644"},
))
@@ -160,7 +160,7 @@ func TestRevert_trees(t *testing.T) {
{
desc: "nonexistent revert fails",
setupRepo: func(t testing.TB, cfg config.Cfg, repoPath string) (ours, revert string) {
- oursOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ oursOid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "apple", Mode: "100644"},
))
diff --git a/cmd/gitaly-git2go-v15/testhelper_test.go b/cmd/gitaly-git2go-v15/testhelper_test.go
index 32f646195..274687cb6 100644
--- a/cmd/gitaly-git2go-v15/testhelper_test.go
+++ b/cmd/gitaly-git2go-v15/testhelper_test.go
@@ -5,7 +5,6 @@ package main
import (
"fmt"
"testing"
- "time"
git "github.com/libgit2/git2go/v33"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
@@ -16,9 +15,9 @@ import (
// DefaultAuthor is the author used by BuildCommit
var DefaultAuthor = git.Signature{
- Name: "Scrooge McDuck",
- Email: "scrooge@mcduck.com",
- When: time.Date(2019, 11, 3, 11, 27, 59, 0, time.FixedZone("", 60*60)),
+ Name: gittest.DefaultCommitterName,
+ Email: gittest.DefaultCommitterMail,
+ When: gittest.DefaultCommitTime,
}
func TestMain(m *testing.M) {
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index 0a22beaaf..99c52683c 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -424,7 +424,6 @@ func testManagerRestore(t *testing.T, ctx context.Context) {
root := gittest.WriteCommit(t, cfg, expectedRepoPath,
gittest.WithBranch("master"),
- gittest.WithParents(),
)
master1 := gittest.WriteCommit(t, cfg, expectedRepoPath,
gittest.WithBranch("master"),
diff --git a/internal/git/catfile/object_info_reader_test.go b/internal/git/catfile/object_info_reader_test.go
index debe5562b..a4e9b3c54 100644
--- a/internal/git/catfile/object_info_reader_test.go
+++ b/internal/git/catfile/object_info_reader_test.go
@@ -182,7 +182,7 @@ func TestObjectInfoReader_queue(t *testing.T) {
Size: int64(len("foobar")),
}
- commitOID := gittest.WriteCommit(t, cfg, repoPath)
+ commitOID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents("master"))
commitInfo := ObjectInfo{
Oid: commitOID,
Type: "commit",
diff --git a/internal/git/gitpipe/catfile_info_test.go b/internal/git/gitpipe/catfile_info_test.go
index 75882b5d4..ad0377d43 100644
--- a/internal/git/gitpipe/catfile_info_test.go
+++ b/internal/git/gitpipe/catfile_info_test.go
@@ -288,7 +288,7 @@ func TestCatfileInfoAllObjects(t *testing.T) {
tree := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
{Path: "foobar", Mode: "100644", OID: blob1},
})
- commit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ commit := gittest.WriteCommit(t, cfg, repoPath)
actualObjects := []CatfileInfoResult{
{ObjectInfo: &catfile.ObjectInfo{Oid: blob1, Type: "blob", Size: 6}},
diff --git a/internal/git/gittest/command_test.go b/internal/git/gittest/command_test.go
index 1cf52d728..2cbe8dae3 100644
--- a/internal/git/gittest/command_test.go
+++ b/internal/git/gittest/command_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
diff --git a/internal/git/gittest/commit.go b/internal/git/gittest/commit.go
index f8902ffe4..526e73545 100644
--- a/internal/git/gittest/commit.go
+++ b/internal/git/gittest/commit.go
@@ -15,9 +15,20 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
)
-const (
- committerName = "Scrooge McDuck"
- committerEmail = "scrooge@mcduck.com"
+var (
+ // DefaultCommitterName is the default name of the committer and author used to create
+ // commits.
+ DefaultCommitterName = "Scrooge McDuck"
+ // DefaultCommitterMail is the default mail of the committer and author used to create
+ // commits.
+ DefaultCommitterMail = "scrooge@mcduck.com"
+ // DefaultCommitTime is the default time used as written by WriteCommit().
+ DefaultCommitTime = time.Date(2019, 11, 3, 11, 27, 59, 0, time.FixedZone("", 60*60))
+ // DefaultCommitterSignature is the default signature in the format like it would be present
+ // in commits: "$name <$email> $unixtimestamp $timezone".
+ DefaultCommitterSignature = fmt.Sprintf(
+ "%s <%s> %d %s", DefaultCommitterName, DefaultCommitterMail, DefaultCommitTime.Unix(), DefaultCommitTime.Format("-0700"),
+ )
)
type writeCommitConfig struct {
@@ -133,12 +144,6 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
}
stdin := bytes.NewBufferString(message)
- // The ID of an arbitrary commit known to exist in the test repository.
- parents := []git.ObjectID{"1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"}
- if writeCommitConfig.parents != nil {
- parents = writeCommitConfig.parents
- }
-
if len(writeCommitConfig.treeEntries) > 0 && writeCommitConfig.treeID != "" {
require.FailNow(t, "cannot set tree entries and tree ID at the same time")
}
@@ -148,15 +153,15 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
tree = WriteTree(t, cfg, repoPath, writeCommitConfig.treeEntries).String()
} else if writeCommitConfig.treeID != "" {
tree = writeCommitConfig.treeID.String()
- } else if len(parents) == 0 {
+ } else if len(writeCommitConfig.parents) == 0 {
// If there are no parents, then we set the root tree to the empty tree.
tree = DefaultObjectHash.EmptyTreeOID.String()
} else {
- tree = parents[0].String() + "^{tree}"
+ tree = writeCommitConfig.parents[0].String() + "^{tree}"
}
if writeCommitConfig.authorName == "" {
- writeCommitConfig.authorName = committerName
+ writeCommitConfig.authorName = DefaultCommitterName
}
if writeCommitConfig.authorDate.IsZero() {
@@ -164,7 +169,7 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
}
if writeCommitConfig.committerName == "" {
- writeCommitConfig.committerName = committerName
+ writeCommitConfig.committerName = DefaultCommitterName
}
if writeCommitConfig.committerDate.IsZero() {
@@ -176,7 +181,7 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
// --allow-empty".
commitArgs := []string{
"-c", fmt.Sprintf("user.name=%s", writeCommitConfig.committerName),
- "-c", fmt.Sprintf("user.email=%s", committerEmail),
+ "-c", fmt.Sprintf("user.email=%s", DefaultCommitterMail),
"-C", repoPath,
"commit-tree", "-F", "-", tree,
}
@@ -196,13 +201,13 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
env = append(env,
fmt.Sprintf("GIT_AUTHOR_DATE=%d %s", writeCommitConfig.authorDate.Unix(), writeCommitConfig.authorDate.Format("-0700")),
fmt.Sprintf("GIT_AUTHOR_NAME=%s", writeCommitConfig.authorName),
- fmt.Sprintf("GIT_AUTHOR_EMAIL=%s", committerEmail),
+ fmt.Sprintf("GIT_AUTHOR_EMAIL=%s", DefaultCommitterMail),
fmt.Sprintf("GIT_COMMITTER_DATE=%d %s", writeCommitConfig.committerDate.Unix(), writeCommitConfig.committerDate.Format("-0700")),
fmt.Sprintf("GIT_COMMITTER_NAME=%s", writeCommitConfig.committerName),
- fmt.Sprintf("GIT_COMMITTER_EMAIL=%s", committerEmail),
+ fmt.Sprintf("GIT_COMMITTER_EMAIL=%s", DefaultCommitterMail),
)
- for _, parent := range parents {
+ for _, parent := range writeCommitConfig.parents {
commitArgs = append(commitArgs, "-p", parent.String())
}
diff --git a/internal/git/gittest/commit_test.go b/internal/git/gittest/commit_test.go
index e970079d2..d1f279554 100644
--- a/internal/git/gittest/commit_test.go
+++ b/internal/git/gittest/commit_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
@@ -15,17 +13,14 @@ import (
func TestWriteCommit(t *testing.T) {
cfg, _, repoPath := setup(t)
- defaultCommitter := "Scrooge McDuck <scrooge@mcduck.com> 1572776879 +0100"
- defaultParentID := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"
+ treeEntryA := TreeEntry{Path: "file", Mode: "100644", Content: "something"}
- revisions := map[git.Revision]git.ObjectID{
- "refs/heads/master": "",
- "refs/heads/master~": "",
- }
- for revision := range revisions {
- oid := Exec(t, cfg, "-C", repoPath, "rev-parse", revision.String())
- revisions[revision] = git.ObjectID(text.ChompBytes(oid))
- }
+ treeA := WriteTree(t, cfg, repoPath, []TreeEntry{treeEntryA})
+ treeB := WriteTree(t, cfg, repoPath, []TreeEntry{
+ {Path: "file", Mode: "100644", Content: "changed"},
+ })
+ commitA := WriteCommit(t, cfg, repoPath, WithTree(treeA))
+ commitB := WriteCommit(t, cfg, repoPath, WithTree(treeB))
for _, tc := range []struct {
desc string
@@ -37,10 +32,9 @@ func TestWriteCommit(t *testing.T) {
{
desc: "no options",
expectedCommit: strings.Join([]string{
- "tree 91639b9835ff541f312fd2735f639a50bf35d472",
- "parent " + defaultParentID,
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
@@ -51,10 +45,9 @@ func TestWriteCommit(t *testing.T) {
WithMessage("my custom message\n\nfoobar\n"),
},
expectedCommit: strings.Join([]string{
- "tree 91639b9835ff541f312fd2735f639a50bf35d472",
- "parent " + defaultParentID,
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"my custom message",
"",
@@ -68,10 +61,9 @@ func TestWriteCommit(t *testing.T) {
WithAuthorDate(time.Date(2005, 4, 7, 15, 13, 13, 0, time.FixedZone("UTC-7", -7*60*60))),
},
expectedCommit: strings.Join([]string{
- "tree 91639b9835ff541f312fd2735f639a50bf35d472",
- "parent " + defaultParentID,
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
"author John Doe <scrooge@mcduck.com> 1112911993 -0700",
- "committer " + defaultCommitter,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
@@ -83,9 +75,8 @@ func TestWriteCommit(t *testing.T) {
WithCommitterDate(time.Date(2005, 4, 7, 15, 13, 13, 0, time.FixedZone("UTC-7", -7*60*60))),
},
expectedCommit: strings.Join([]string{
- "tree 91639b9835ff541f312fd2735f639a50bf35d472",
- "parent " + defaultParentID,
- "author Scrooge McDuck <scrooge@mcduck.com> 1572776879 +0100",
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
+ "author " + DefaultCommitterSignature,
"committer John Doe <scrooge@mcduck.com> 1112911993 -0700",
"",
"message",
@@ -97,9 +88,9 @@ func TestWriteCommit(t *testing.T) {
WithParents(),
},
expectedCommit: strings.Join([]string{
- "tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904",
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
@@ -107,14 +98,14 @@ func TestWriteCommit(t *testing.T) {
{
desc: "with multiple parents",
opts: []WriteCommitOption{
- WithParents(revisions["refs/heads/master"], revisions["refs/heads/master~"]),
+ WithParents(commitA, commitB),
},
expectedCommit: strings.Join([]string{
- "tree 07f8147e8e73aab6c935c296e8cdc5194dee729b",
- "parent 1e292f8fedd741b75372e19097c76d327140c312",
- "parent 7975be0116940bf2ad4321f79d02a55c5f7779aa",
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + treeA.String(),
+ "parent " + commitA.String(),
+ "parent " + commitB.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
@@ -125,10 +116,9 @@ func TestWriteCommit(t *testing.T) {
WithBranch("foo"),
},
expectedCommit: strings.Join([]string{
- "tree 91639b9835ff541f312fd2735f639a50bf35d472",
- "parent " + defaultParentID,
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + DefaultObjectHash.EmptyTreeOID.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
@@ -137,44 +127,26 @@ func TestWriteCommit(t *testing.T) {
{
desc: "with tree entry",
opts: []WriteCommitOption{
- WithTreeEntries(TreeEntry{
- Content: "foobar",
- Mode: "100644",
- Path: "file",
- }),
+ WithTreeEntries(treeEntryA),
},
expectedCommit: strings.Join([]string{
- "tree 0a2fde9f84d2642adbfdf7c37560005e2532fd31",
- "parent " + defaultParentID,
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + treeA.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
- expectedTreeEntries: []TreeEntry{
- {
- Content: "foobar",
- Mode: "100644",
- Path: "file",
- },
- },
+ expectedTreeEntries: []TreeEntry{treeEntryA},
},
{
desc: "with tree",
opts: []WriteCommitOption{
- WithTree(WriteTree(t, cfg, repoPath, []TreeEntry{
- {
- Content: "something",
- Mode: "100644",
- Path: "file",
- },
- })),
+ WithTree(treeA),
},
expectedCommit: strings.Join([]string{
- "tree 52193934b12dbe23bf1d663802d77a04792a79ac",
- "parent " + defaultParentID,
- "author " + defaultCommitter,
- "committer " + defaultCommitter,
+ "tree " + treeA.String(),
+ "author " + DefaultCommitterSignature,
+ "committer " + DefaultCommitterSignature,
"",
"message",
}, "\n"),
diff --git a/internal/git/gittest/delta_islands.go b/internal/git/gittest/delta_islands.go
index 7909c3049..c582d0813 100644
--- a/internal/git/gittest/delta_islands.go
+++ b/internal/git/gittest/delta_islands.go
@@ -50,7 +50,7 @@ func TestDeltaIslands(t *testing.T, cfg config.Cfg, repoPath string, isPoolRepo
// chains, and thus neither of the two blobs should use the bad blob as delta base.
require.NoError(t, repack(), "repack after delta island setup")
require.Equal(t, blob2ID, deltaBase(t, cfg, repoPath, blob1ID), "blob 1 delta base should be blob 2 after repack")
- require.Equal(t, git.ObjectHashSHA1.ZeroOID.String(), deltaBase(t, cfg, repoPath, blob2ID), "blob 2 should not be delta compressed after repack")
+ require.Equal(t, DefaultObjectHash.ZeroOID.String(), deltaBase(t, cfg, repoPath, blob2ID), "blob 2 should not be delta compressed after repack")
}
func commitBlob(t *testing.T, cfg config.Cfg, repoPath, ref string, content string) string {
@@ -62,7 +62,6 @@ func commitBlob(t *testing.T, cfg config.Cfg, repoPath, ref string, content stri
WithTreeEntries(TreeEntry{
Mode: "100644", OID: blobID, Path: "file",
}),
- WithParents(),
)
Exec(t, cfg, "-C", repoPath, "update-ref", ref, commitID.String())
diff --git a/internal/git/gittest/intercepting_command_factory_test.go b/internal/git/gittest/intercepting_command_factory_test.go
index 1dc2070b9..d93f68afc 100644
--- a/internal/git/gittest/intercepting_command_factory_test.go
+++ b/internal/git/gittest/intercepting_command_factory_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
diff --git a/internal/git/gittest/objects.go b/internal/git/gittest/objects.go
index aafca61b2..0a740326e 100644
--- a/internal/git/gittest/objects.go
+++ b/internal/git/gittest/objects.go
@@ -15,6 +15,11 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
)
+// ObjectHashIsSHA256 returns if the current default object hash is SHA256.
+func ObjectHashIsSHA256() bool {
+ return DefaultObjectHash.EmptyTreeOID == git.ObjectHashSHA256.EmptyTreeOID
+}
+
// RequireObjectExists asserts that the given repository does contain an object with the specified
// object ID.
func RequireObjectExists(t testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID) {
diff --git a/internal/git/gittest/ref_test.go b/internal/git/gittest/ref_test.go
index 0753ef00f..afbf5c6b1 100644
--- a/internal/git/gittest/ref_test.go
+++ b/internal/git/gittest/ref_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
@@ -12,8 +10,7 @@ import (
func TestResolveRevision(t *testing.T) {
cfg, _, repoPath := setup(t)
- require.Equal(t,
- git.ObjectID("1e292f8fedd741b75372e19097c76d327140c312"),
- ResolveRevision(t, cfg, repoPath, "refs/heads/master"),
- )
+ commitID := WriteCommit(t, cfg, repoPath, WithBranch(git.DefaultBranch))
+
+ require.Equal(t, commitID, ResolveRevision(t, cfg, repoPath, git.DefaultBranch))
}
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go
index 1b4b08bb3..201f459b1 100644
--- a/internal/git/gittest/repo.go
+++ b/internal/git/gittest/repo.go
@@ -144,6 +144,10 @@ func CreateRepository(ctx context.Context, t testing.TB, cfg config.Cfg, configs
}
if opts.Seed != "" {
+ if ObjectHashIsSHA256() {
+ require.FailNow(t, "seeded repository creation not supported with SHA256")
+ }
+
_, err := client.CreateRepositoryFromURL(ctx, &gitalypb.CreateRepositoryFromURLRequest{
Repository: repository,
Url: testRepositoryPath(t, opts.Seed),
@@ -290,6 +294,10 @@ type CloneRepoOpts struct {
// CloneRepo clones a new copy of test repository under a subdirectory in the storage root. You can
// either pass no or exactly one CloneRepoOpts.
func CloneRepo(t testing.TB, cfg config.Cfg, storage config.Storage, opts ...CloneRepoOpts) (*gitalypb.Repository, string) {
+ if ObjectHashIsSHA256() {
+ require.FailNow(t, "seeded repository creation not supported with SHA256")
+ }
+
require.Less(t, len(opts), 2, "you must either pass no or exactly one option")
opt := CloneRepoOpts{}
diff --git a/internal/git/gittest/repository_suite.go b/internal/git/gittest/repository_suite.go
index 83db63614..676e17564 100644
--- a/internal/git/gittest/repository_suite.go
+++ b/internal/git/gittest/repository_suite.go
@@ -96,7 +96,7 @@ func testRepositoryHasBranches(t *testing.T, cfg config.Cfg, getRepository GetRe
repo, repoPath := getRepository(ctx, t, false)
- emptyCommit := text.ChompBytes(Exec(t, cfg, "-C", repoPath, "commit-tree", git.ObjectHashSHA1.EmptyTreeOID.String()))
+ emptyCommit := text.ChompBytes(Exec(t, cfg, "-C", repoPath, "commit-tree", DefaultObjectHash.EmptyTreeOID.String()))
Exec(t, cfg, "-C", repoPath, "update-ref", "refs/headsbranch", emptyCommit)
@@ -124,7 +124,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository
desc: "default ref",
repo: func(t *testing.T) git.Repository {
repo, repoPath := getRepository(ctx, t, false)
- oid := WriteCommit(t, cfg, repoPath, WithParents(), WithBranch("apple"))
+ oid := WriteCommit(t, cfg, repoPath, WithBranch("apple"))
WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("main"))
return repo
},
@@ -134,7 +134,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository
desc: "legacy default ref",
repo: func(t *testing.T) git.Repository {
repo, repoPath := getRepository(ctx, t, false)
- oid := WriteCommit(t, cfg, repoPath, WithParents(), WithBranch("apple"))
+ oid := WriteCommit(t, cfg, repoPath, WithBranch("apple"))
WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("master"))
return repo
},
@@ -151,7 +151,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository
desc: "one branch",
repo: func(t *testing.T) git.Repository {
repo, repoPath := getRepository(ctx, t, false)
- WriteCommit(t, cfg, repoPath, WithParents(), WithBranch("apple"))
+ WriteCommit(t, cfg, repoPath, WithBranch("apple"))
return repo
},
expectedName: git.NewReferenceNameFromBranchName("apple"),
@@ -160,7 +160,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository
desc: "no default branches",
repo: func(t *testing.T) git.Repository {
repo, repoPath := getRepository(ctx, t, false)
- oid := WriteCommit(t, cfg, repoPath, WithParents(), WithBranch("apple"))
+ oid := WriteCommit(t, cfg, repoPath, WithBranch("apple"))
WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("banana"))
return repo
},
diff --git a/internal/git/gittest/tag.go b/internal/git/gittest/tag.go
index 09cfa2f5d..047d952b3 100644
--- a/internal/git/gittest/tag.go
+++ b/internal/git/gittest/tag.go
@@ -39,13 +39,10 @@ func WriteTag(
config = optionalConfig[0]
}
- committerName := "Scrooge McDuck"
- committerEmail := "scrooge@mcduck.com"
-
args := []string{
"-C", repoPath,
- "-c", fmt.Sprintf("user.name=%s", committerName),
- "-c", fmt.Sprintf("user.email=%s", committerEmail),
+ "-c", fmt.Sprintf("user.name=%s", DefaultCommitterName),
+ "-c", fmt.Sprintf("user.email=%s", DefaultCommitterMail),
"tag",
}
diff --git a/internal/git/gittest/testhelper_test.go b/internal/git/gittest/testhelper_test.go
index 42e7bf48c..dd24561fa 100644
--- a/internal/git/gittest/testhelper_test.go
+++ b/internal/git/gittest/testhelper_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
@@ -54,7 +52,7 @@ func setup(t testing.TB) (config.Cfg, *gitalypb.Repository, string) {
require.NoError(t, cfg.Validate())
- repo, repoPath := CloneRepo(t, cfg, cfg.Storages[0])
+ repo, repoPath := InitRepo(t, cfg, cfg.Storages[0])
return cfg, repo, repoPath
}
diff --git a/internal/git/gittest/tree.go b/internal/git/gittest/tree.go
index 7b93c996f..41194ed72 100644
--- a/internal/git/gittest/tree.go
+++ b/internal/git/gittest/tree.go
@@ -2,7 +2,6 @@ package gittest
import (
"bytes"
- "crypto/sha1"
"encoding/hex"
"fmt"
"testing"
@@ -36,8 +35,12 @@ func RequireTree(t testing.TB, cfg config.Cfg, repoPath, treeish string, expecte
}
blob := fmt.Sprintf("blob %d\000%s", len(entry.Content), entry.Content)
- hash := sha1.Sum([]byte(blob))
- expectedEntries[i].OID = git.ObjectID(hex.EncodeToString(hash[:]))
+
+ hasher := DefaultObjectHash.Hash()
+ _, err := hasher.Write([]byte(blob))
+ require.NoError(t, err)
+
+ expectedEntries[i].OID = git.ObjectID(hex.EncodeToString(hasher.Sum(nil)))
}
var actualEntries []TreeEntry
diff --git a/internal/git/gittest/tree_test.go b/internal/git/gittest/tree_test.go
index 09ce729d7..c136857c6 100644
--- a/internal/git/gittest/tree_test.go
+++ b/internal/git/gittest/tree_test.go
@@ -1,18 +1,16 @@
-//go:build !gitaly_test_sha256
-
package gittest
import (
"strings"
"testing"
- "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
)
func TestWriteTree(t *testing.T) {
cfg, _, repoPath := setup(t)
+ differentContentBlobID := WriteBlob(t, cfg, repoPath, []byte("different content"))
blobID := WriteBlob(t, cfg, repoPath, []byte("foobar\n"))
treeID := WriteTree(t, cfg, repoPath, []TreeEntry{
{
@@ -26,7 +24,6 @@ func TestWriteTree(t *testing.T) {
desc string
entries []TreeEntry
expectedEntries []TreeEntry
- expectedOID git.ObjectID
}{
{
desc: "entry with blob OID",
@@ -45,7 +42,6 @@ func TestWriteTree(t *testing.T) {
Path: "file",
},
},
- expectedOID: "54a22f36d78d0ba7964f71ff72c7309edecab857",
},
{
desc: "entry with blob content",
@@ -58,13 +54,12 @@ func TestWriteTree(t *testing.T) {
},
expectedEntries: []TreeEntry{
{
- OID: "323fae03f4606ea9991df8befbb2fca795e648fa",
+ OID: blobID,
Content: "foobar\n",
Mode: "100644",
Path: "file",
},
},
- expectedOID: "54a22f36d78d0ba7964f71ff72c7309edecab857",
},
{
desc: "entry with tree OID",
@@ -83,7 +78,6 @@ func TestWriteTree(t *testing.T) {
Path: "dir/file",
},
},
- expectedOID: "c69f8fc9c97fcae2a80ba1578c493171984d810a",
},
{
desc: "mixed tree and blob entries",
@@ -118,29 +112,27 @@ func TestWriteTree(t *testing.T) {
Path: "file1",
},
{
- OID: "9b62abfb7f69b6d5801a232a9e6c332a10c9cafc",
+ OID: differentContentBlobID,
Content: "different content",
Mode: "100644",
Path: "file2",
},
},
- expectedOID: "70a96b29b67eb29344f399c1c4bc0047568e8dba",
},
{
desc: "two entries with nonexistant objects",
entries: []TreeEntry{
{
- OID: git.ObjectID(strings.Repeat("1", 40)),
+ OID: git.ObjectID(strings.Repeat("1", DefaultObjectHash.Hash().Size()*2)),
Mode: "100644",
Path: "file",
},
{
- OID: git.ObjectID(strings.Repeat("0", 40)),
+ OID: DefaultObjectHash.ZeroOID,
Mode: "100644",
Path: "file",
},
},
- expectedOID: "09e7f53dec572807e651fc368d834f9744a5a42c",
},
} {
t.Run(tc.desc, func(t *testing.T) {
@@ -149,8 +141,6 @@ func TestWriteTree(t *testing.T) {
if tc.expectedEntries != nil {
RequireTree(t, cfg, repoPath, oid.String(), tc.expectedEntries)
}
-
- require.Equal(t, tc.expectedOID, oid)
})
}
}
diff --git a/internal/git/housekeeping/objects_test.go b/internal/git/housekeeping/objects_test.go
index 7d56e1d4b..6156c65bf 100644
--- a/internal/git/housekeeping/objects_test.go
+++ b/internal/git/housekeeping/objects_test.go
@@ -40,7 +40,7 @@ func TestRepackObjects(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
requireObjectCount(t, repoPath, 1)
requirePackfileCount(t, repoPath, 0)
diff --git a/internal/git/housekeeping/optimize_repository_test.go b/internal/git/housekeeping/optimize_repository_test.go
index c99125018..886765b5a 100644
--- a/internal/git/housekeeping/optimize_repository_test.go
+++ b/internal/git/housekeeping/optimize_repository_test.go
@@ -385,7 +385,7 @@ func TestPackRefsIfNeeded(t *testing.T) {
repo := localrepo.NewTestRepo(t, cfg, repoProto)
// Write an empty commit such that we can create valid refs.
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
looseRefContent := []byte(commitID.String() + "\n")
// We first create a single big packfile which is used to determine the
@@ -685,7 +685,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1
})
for i := 0; i < 16; i++ {
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch(fmt.Sprintf("branch-%d", i)))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch(fmt.Sprintf("branch-%d", i)))
}
gittest.Exec(t, cfg, "-C", repoPath, "repack", "-A", "--write-bitmap-index")
@@ -1008,7 +1008,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository without commit-graph",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
return repoProto, repoPath
},
expectedWrite: true,
@@ -1021,7 +1021,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository with old-style unsplit commit-graph",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
// Write a non-split commit-graph with bloom filters. We should
// always rewrite the commit-graphs when we're not using a split
@@ -1043,7 +1043,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository with split commit-graph without bitmap",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
// Generate a split commit-graph, but don't enable computation of
// changed paths. This should trigger a rewrite so that we can
@@ -1062,7 +1062,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository with split commit-graph with bitmap without repack",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
// Write a split commit-graph with bitmaps. This is the state we
// want to be in.
@@ -1081,7 +1081,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository with split commit-graph with bitmap with repack",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
// Write a split commit-graph with bitmaps. This is the state we
// want to be in, so there is no write required if we didn't also
@@ -1101,7 +1101,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
desc: "repository with split commit-graph with bitmap with pruned objects",
setup: func(t *testing.T) (*gitalypb.Repository, string) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
// Write a split commit-graph with bitmaps. This is the state we
// want to be in, so there is no write required if we didn't also
@@ -1145,7 +1145,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) {
repo := localrepo.NewTestRepo(t, cfg, repoProto)
// Write a first commit-graph that contains the root commit, only.
- rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
gittest.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
// Write a second, incremental commit-graph that contains a commit we're about to
diff --git a/internal/git/localrepo/repo_test.go b/internal/git/localrepo/repo_test.go
index 7b433083a..8d68dc821 100644
--- a/internal/git/localrepo/repo_test.go
+++ b/internal/git/localrepo/repo_test.go
@@ -84,7 +84,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "file", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -102,7 +101,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "file", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -119,7 +117,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
rootCommitID := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "file", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -145,7 +142,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
rootCommitID := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "file", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -173,7 +169,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -181,7 +176,6 @@ func TestSize(t *testing.T) {
)
gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("x", 2000)},
),
@@ -202,7 +196,6 @@ func TestSize(t *testing.T) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -231,7 +224,6 @@ func TestSize(t *testing.T) {
for _, path := range []string{repoPath, poolPath} {
gittest.WriteCommit(t, cfg, path,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -264,7 +256,6 @@ func TestSize(t *testing.T) {
// exclude it from our size calculations.
for _, path := range []string{repoPath, poolPath} {
gittest.WriteCommit(t, cfg, path,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
@@ -296,7 +287,6 @@ func TestSize(t *testing.T) {
// We first write one blob into the repo that is the same
// across both repositories.
rootCommitID := gittest.WriteCommit(t, cfg, path,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "1kbblob", Mode: "100644", Content: strings.Repeat("a", 1000)},
),
diff --git a/internal/git/object_id.go b/internal/git/object_id.go
index 4d6083a12..88db74d44 100644
--- a/internal/git/object_id.go
+++ b/internal/git/object_id.go
@@ -3,12 +3,14 @@ package git
import (
"bytes"
"context"
+ "crypto/sha1"
+ "crypto/sha256"
"encoding/hex"
"errors"
"fmt"
+ "hash"
"regexp"
- "gitlab.com/gitlab-org/gitaly/v15/internal/command"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
)
@@ -16,6 +18,7 @@ var (
// ObjectHashSHA1 is the implementation of an object ID via SHA1.
ObjectHashSHA1 = ObjectHash{
regexp: regexp.MustCompile(`\A[0-9a-f]{40}\z`),
+ Hash: sha1.New,
EmptyTreeOID: ObjectID("4b825dc642cb6eb9a060e54bf8d69288fbee4904"),
ZeroOID: ObjectID("0000000000000000000000000000000000000000"),
}
@@ -23,6 +26,7 @@ var (
// ObjectHashSHA256 is the implementation of an object ID via SHA256.
ObjectHashSHA256 = ObjectHash{
regexp: regexp.MustCompile(`\A[0-9a-f]{64}\z`),
+ Hash: sha256.New,
EmptyTreeOID: ObjectID("6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321"),
ZeroOID: ObjectID("0000000000000000000000000000000000000000000000000000000000000000"),
}
@@ -35,6 +39,8 @@ var (
// ObjectHash is a hash-function specific implementation of an object ID.
type ObjectHash struct {
regexp *regexp.Regexp
+ // Hash is the hashing function used to hash objects.
+ Hash func() hash.Hash
// EmptyTreeOID is the object ID of the tree object that has no directory entries.
EmptyTreeOID ObjectID
// ZeroOID is the special value that Git uses to signal a ref or object does not exist
@@ -43,17 +49,15 @@ type ObjectHash struct {
// DetectObjectHash detects the object-hash used by the given repository.
func DetectObjectHash(ctx context.Context, repoExecutor RepositoryExecutor) (ObjectHash, error) {
- var stdout bytes.Buffer
+ var stdout, stderr bytes.Buffer
if err := repoExecutor.ExecAndWait(ctx, SubCmd{
- Name: "config",
- Args: []string{"extensions.objectFormat"},
- }, WithStdout(&stdout)); err != nil {
- if status, ok := command.ExitStatus(err); ok && status == 1 {
- return ObjectHashSHA1, nil
- }
-
- return ObjectHash{}, fmt.Errorf("reading object format: %w", err)
+ Name: "rev-parse",
+ Flags: []Option{
+ Flag{"--show-object-format"},
+ },
+ }, WithStdout(&stdout), WithStderr(&stderr)); err != nil {
+ return ObjectHash{}, fmt.Errorf("reading object format: %w, stderr: %q", err, stderr.String())
}
objectFormat := text.ChompBytes(stdout.Bytes())
diff --git a/internal/git/object_id_test.go b/internal/git/object_id_test.go
index a6b62ffdc..44ac98a46 100644
--- a/internal/git/object_id_test.go
+++ b/internal/git/object_id_test.go
@@ -53,7 +53,10 @@ func TestDetectObjectHash(t *testing.T) {
ObjectFormat: "sha1",
})
- // Explicitly set the object format to SHA1.
+ // Explicitly set the object format to SHA1. Note that setting the
+ // object format explicitly requires the repository format version
+ // to be at least `1`.
+ gittest.Exec(t, cfg, "-C", repoPath, "config", "core.repositoryFormatVersion", "1")
gittest.Exec(t, cfg, "-C", repoPath, "config", "extensions.objectFormat", "sha1")
return repo
@@ -77,6 +80,22 @@ func TestDetectObjectHash(t *testing.T) {
expectedHash: git.ObjectHashSHA256,
},
{
+ desc: "invalid repository configuration",
+ setup: func(t *testing.T) *gitalypb.Repository {
+ repo, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0], gittest.InitRepoOpts{
+ ObjectFormat: "sha1",
+ })
+
+ gittest.Exec(t, cfg, "-C", repoPath, "config", "extensions.objectFormat", "sha1")
+
+ return repo
+ },
+ expectedErr: fmt.Errorf(
+ "reading object format: exit status 128, stderr: %q",
+ "fatal: repo version is 0, but v1-only extension found:\n\tobjectformat\n",
+ ),
+ },
+ {
desc: "unknown hash",
setup: func(t *testing.T) *gitalypb.Repository {
repo, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
@@ -86,7 +105,9 @@ func TestDetectObjectHash(t *testing.T) {
return repo
},
- expectedErr: fmt.Errorf("reading object format: exit status 128"),
+ expectedErr: fmt.Errorf(
+ "reading object format: exit status 128, stderr: \"error: invalid value for 'extensions.objectformat'",
+ ),
},
} {
t.Run(tc.desc, func(t *testing.T) {
@@ -95,10 +116,16 @@ func TestDetectObjectHash(t *testing.T) {
hash, err := git.DetectObjectHash(ctx, repo)
if tc.expectedErr != nil {
- require.EqualError(t, err, tc.expectedErr.Error())
+ require.Error(t, err)
+ require.Contains(t, err.Error(), tc.expectedErr.Error())
} else {
require.NoError(t, err)
}
+
+ // Function pointers cannot be compared, so we need to unset them.
+ hash.Hash = nil
+ tc.expectedHash.Hash = nil
+
require.Equal(t, tc.expectedHash, hash)
})
}
diff --git a/internal/git/objectpool/fetch_test.go b/internal/git/objectpool/fetch_test.go
index 880fa2dd3..bb7b5c921 100644
--- a/internal/git/objectpool/fetch_test.go
+++ b/internal/git/objectpool/fetch_test.go
@@ -223,7 +223,6 @@ func testFetchFromOriginRefUpdates(t *testing.T, ctx context.Context) {
// it's easy enough to do, so it doesn't hurt.
for i := 0; i < 32; i++ {
newRefs[fmt.Sprintf("heads/branch-%d", i)] = gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithMessage(strconv.Itoa(i)),
).String()
}
@@ -259,7 +258,7 @@ func testFetchFromOriginRefs(t *testing.T, ctx context.Context) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries())
+ commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries())
for _, ref := range []string{"refs/heads/master", "refs/environments/1", "refs/tags/lightweight-tag"} {
gittest.Exec(t, cfg, "-C", repoPath, "update-ref", ref, commitID.String())
}
diff --git a/internal/git/stats/profile_test.go b/internal/git/stats/profile_test.go
index 5a2b5bd1f..0b6b3030c 100644
--- a/internal/git/stats/profile_test.go
+++ b/internal/git/stats/profile_test.go
@@ -51,7 +51,6 @@ func TestRepositoryProfile(t *testing.T) {
gittest.WithTreeEntries(gittest.TreeEntry{
Mode: "100644", Path: "blob", OID: git.ObjectID(blobID),
}),
- gittest.WithParents(),
)
gittest.Exec(t, cfg, "-C", testRepoPath, "update-ref", "refs/heads/"+blobID, commitID.String())
}
diff --git a/internal/git/helper_test.go b/internal/git/testhelper_test.go
index 21a27883e..21a27883e 100644
--- a/internal/git/helper_test.go
+++ b/internal/git/testhelper_test.go
diff --git a/internal/gitaly/linguist/linguist_test.go b/internal/gitaly/linguist/linguist_test.go
index c5427bb6a..82eb7bb95 100644
--- a/internal/gitaly/linguist/linguist_test.go
+++ b/internal/gitaly/linguist/linguist_test.go
@@ -164,7 +164,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) {
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- oldCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(
+ oldCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
gittest.TreeEntry{Path: "main.rb", Content: "require 'fileutils'", Mode: "100644"},
))
newCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(oldCommitID), gittest.WithTreeEntries(
diff --git a/internal/gitaly/service/commit/check_objects_exist_test.go b/internal/gitaly/service/commit/check_objects_exist_test.go
index 5873ca776..9628bba02 100644
--- a/internal/gitaly/service/commit/check_objects_exist_test.go
+++ b/internal/gitaly/service/commit/check_objects_exist_test.go
@@ -23,7 +23,7 @@ func TestCheckObjectsExist(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
commitID1 := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithBranch("master"), gittest.WithMessage("commit-1"), gittest.WithParents(),
+ gittest.WithBranch("master"), gittest.WithMessage("commit-1"),
)
commitID2 := gittest.WriteCommit(t, cfg, repoPath,
gittest.WithBranch("feature"), gittest.WithMessage("commit-2"), gittest.WithParents(commitID1),
diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go
index e1b9fcd23..42470db91 100644
--- a/internal/gitaly/service/commit/find_commit_test.go
+++ b/internal/gitaly/service/commit/find_commit_test.go
@@ -203,14 +203,14 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
Id: bigCommitID.String(),
Subject: []byte("An empty commit with REALLY BIG message"),
Author: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
Date: &timestamppb.Timestamp{Seconds: bigCommit.Author.Date.Seconds},
Timezone: []byte("+0100"),
},
Committer: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
Date: &timestamppb.Timestamp{Seconds: bigCommit.Committer.Date.Seconds},
Timezone: []byte("+0100"),
},
diff --git a/internal/gitaly/service/commit/list_all_commits_test.go b/internal/gitaly/service/commit/list_all_commits_test.go
index 4efa1b383..c0af3db84 100644
--- a/internal/gitaly/service/commit/list_all_commits_test.go
+++ b/internal/gitaly/service/commit/list_all_commits_test.go
@@ -117,7 +117,6 @@ func TestListAllCommits(t *testing.T) {
// manually here and write the commit into the quarantine object directory.
commitID := gittest.WriteCommit(t, cfg, repoPath,
gittest.WithAlternateObjectDirectory(filepath.Join(repoPath, quarantineDir)),
- gittest.WithParents(),
)
// We now expect only the quarantined commit to be returned.
@@ -133,14 +132,14 @@ func TestListAllCommits(t *testing.T) {
BodySize: 7,
TreeId: "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
Author: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
Date: &timestamppb.Timestamp{Seconds: 1572776879},
Timezone: []byte("+0100"),
},
Committer: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
Date: &timestamppb.Timestamp{Seconds: 1572776879},
Timezone: []byte("+0100"),
},
diff --git a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go
index 122af5123..e9d897834 100644
--- a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go
+++ b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go
@@ -358,7 +358,7 @@ func TestSuccessfulListLastCommitsForTreeRequestWithGlobCharacters(t *testing.T)
Path: ":wq", Mode: "040000", OID: gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
{Path: "README.md", Mode: "100644", Content: "something"},
}),
- }), gittest.WithParents())
+ }))
t.Run("with literal pathspecs", func(t *testing.T) {
stream, err := client.ListLastCommitsForTree(ctx, &gitalypb.ListLastCommitsForTreeRequest{
diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go
index af2c64ca2..659c36651 100644
--- a/internal/gitaly/service/commit/tree_entries_test.go
+++ b/internal/gitaly/service/commit/tree_entries_test.go
@@ -25,7 +25,7 @@ func TestGetTreeEntries_curlyBraces(t *testing.T) {
ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t)
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTreeEntries(gittest.TreeEntry{
+ commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(gittest.TreeEntry{
Path: "issue-46261", Mode: "040000", OID: gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
{
Path: "folder", Mode: "040000", OID: gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
@@ -582,7 +582,7 @@ func TestGetTreeEntries_deepFlatpath(t *testing.T) {
treeID = gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{treeEntry})
}
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithTree(treeID))
+ commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTree(treeID))
// We make a non-recursive request which tries to fetch tree entrie for the tree structure
// we have created above. This should return a single entry, which is the directory we're
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index 6dfda1eab..a8dddf7aa 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -825,6 +825,7 @@ func TestResolveConflictsQuarantine(t *testing.T) {
sourceBlobOID := gittest.WriteBlob(t, cfg, sourceRepoPath, []byte("contents-1\n"))
sourceCommitOID := gittest.WriteCommit(t, cfg, sourceRepoPath,
+ gittest.WithParents("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"),
gittest.WithTreeEntries(gittest.TreeEntry{
Path: "file.txt", OID: sourceBlobOID, Mode: "100644",
}),
@@ -847,6 +848,7 @@ func TestResolveConflictsQuarantine(t *testing.T) {
})
targetBlobOID := gittest.WriteBlob(t, cfg, targetRepoPath, []byte("contents-2\n"))
targetCommitOID := gittest.WriteCommit(t, cfg, targetRepoPath,
+ gittest.WithParents("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"),
gittest.WithTreeEntries(gittest.TreeEntry{
Path: "file.txt", OID: targetBlobOID, Mode: "100644",
}),
diff --git a/internal/gitaly/service/diff/raw_test.go b/internal/gitaly/service/diff/raw_test.go
index 5183ebfad..9dff35451 100644
--- a/internal/gitaly/service/diff/raw_test.go
+++ b/internal/gitaly/service/diff/raw_test.go
@@ -6,7 +6,6 @@ import (
"io"
"regexp"
"testing"
- "time"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
@@ -47,9 +46,9 @@ func TestRawDiff_successful(t *testing.T) {
require.NoError(t, err)
signature := git2go.Signature{
- Name: "Scrooge McDuck",
- Email: "scrooge@mcduck.com",
- When: time.Unix(12345, 0),
+ Name: gittest.DefaultCommitterName,
+ Email: gittest.DefaultCommitterMail,
+ When: gittest.DefaultCommitTime,
}
// Now that we have read the patch in we verify that it indeed round-trips to the same tree
@@ -150,9 +149,9 @@ func TestRawPatch_successful(t *testing.T) {
require.NoError(t, err)
signature := git2go.Signature{
- Name: "Scrooge McDuck",
- Email: "scrooge@mcduck.com",
- When: time.Unix(12345, 0),
+ Name: gittest.DefaultCommitterName,
+ Email: gittest.DefaultCommitterMail,
+ When: gittest.DefaultCommitTime,
}
// Now that we have read the patch in we verify that it indeed round-trips to the same tree
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index b3948c5f1..b07fb5060 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -501,7 +501,7 @@ func TestUserDeleteBranch_allowed(t *testing.T) {
))
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("branch"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("branch"))
response, err := client.UserDeleteBranch(ctx, &gitalypb.UserDeleteBranchRequest{
Repository: repo,
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index a63655401..7bfbf37d6 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -97,7 +97,6 @@ func TestUserRebaseConfirmable_skipEmptyCommits(t *testing.T) {
// This is the base commit from which both "theirs" and "ours" branch from".
baseCommit := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Mode: "100644", Path: "README", Content: "a\nb\nc\nd\ne\nf\n"},
),
@@ -175,9 +174,9 @@ func TestUserRebaseConfirmable_skipEmptyCommits(t *testing.T) {
ParentIds: []string{theirs.String()},
TreeId: "b68aeb18813d7f2e180f2cc0bccc128511438b29",
Author: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
Committer: &gitalypb.CommitAuthor{
@@ -626,7 +625,6 @@ func TestUserRebaseConfirmable_deletedFileInLocalRepo(t *testing.T) {
var rootCommitID git.ObjectID
for _, path := range []string{localRepoPath, remoteRepoPath} {
rootCommitID = gittest.WriteCommit(t, cfg, path,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "change-me", Mode: "100644", Content: "unchanged contents"},
gittest.TreeEntry{Path: "delete-me", Mode: "100644", Content: "useless stuff"},
@@ -697,7 +695,6 @@ func TestUserRebaseConfirmable_deletedFileInRemoteRepo(t *testing.T) {
var rootCommitID git.ObjectID
for _, path := range []string{localRepoPath, remoteRepoPath} {
rootCommitID = gittest.WriteCommit(t, cfg, path,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: "unchanged", Mode: "100644", Content: "unchanged contents"},
gittest.TreeEntry{Path: "delete-me", Mode: "100644", Content: "useless stuff"},
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index ae063e9a4..3a418a6b0 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -328,7 +328,7 @@ func TestUserSquash_renames(t *testing.T) {
repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg)
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
repo := localrepo.NewTestRepo(t, cfg, repoProto)
@@ -336,7 +336,6 @@ func TestUserSquash_renames(t *testing.T) {
renamedFilename := "renamed-file.txt"
rootCommitID := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
gittest.WithTreeEntries(
gittest.TreeEntry{Path: originalFilename, Mode: "100644", Content: "This is a test"},
),
@@ -422,7 +421,7 @@ func TestUserSquash_emptyCommit(t *testing.T) {
// Set up history with two diverging lines of branches, where both sides have implemented
// the same changes. During merge, the diff will thus become empty.
base := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(), gittest.WithTreeEntries(
+ gittest.WithTreeEntries(
gittest.TreeEntry{Path: "a", Content: "base", Mode: "100644"},
),
)
@@ -670,7 +669,7 @@ func TestUserSquash_ancestry(t *testing.T) {
// We create an empty parent commit and two commits which both branch off from it. As a
// result, they are not direct ancestors of each other.
- parent := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("p"), gittest.WithTreeEntries(), gittest.WithParents())
+ parent := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("p"), gittest.WithTreeEntries())
commit1 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("1"),
gittest.WithTreeEntries(gittest.TreeEntry{Path: "a", Mode: "100644", Content: "a-content"}),
gittest.WithParents(parent),
@@ -805,7 +804,6 @@ func TestUserSquash_squashingMerge(t *testing.T) {
base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("base"),
gittest.WithTreeEntries(gittest.TreeEntry{Path: "a", Mode: "100644", Content: "base-content"}),
- gittest.WithParents(),
)
ours := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("ours"),
gittest.WithTreeEntries(gittest.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content"}),
diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go
index 9025af082..6ae5ec5fe 100644
--- a/internal/gitaly/service/ref/find_all_tags_test.go
+++ b/internal/gitaly/service/ref/find_all_tags_test.go
@@ -98,9 +98,9 @@ func TestFindAllTags_successful(t *testing.T) {
Message: []byte("commit tag with a commit sha as the name"),
MessageSize: 40,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -111,9 +111,9 @@ func TestFindAllTags_successful(t *testing.T) {
Message: []byte("tag of a tag"),
MessageSize: 12,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -164,8 +164,8 @@ func TestFindAllTags_successful(t *testing.T) {
Message: truncatedPGPTagMsg[146:10386], // first 10240 bytes of tag message
MessageSize: 11148,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
Date: &timestamppb.Timestamp{Seconds: 1393491261},
Timezone: []byte("+0100"),
},
@@ -177,9 +177,9 @@ func TestFindAllTags_successful(t *testing.T) {
Message: []byte("Blob tag"),
MessageSize: 8,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -209,9 +209,9 @@ func TestFindAllTags_successful(t *testing.T) {
MessageSize: int64(len(bigMessage)),
TargetCommit: gitCommit,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -227,9 +227,7 @@ func TestFindAllTags_simpleNestedTags(t *testing.T) {
repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg)
- commitID := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithParents(),
- )
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
tagID := gittest.WriteTag(t, cfg, repoPath, "my/nested/tag", commitID.Revision())
@@ -250,15 +248,15 @@ func TestFindAllTags_simpleNestedTags(t *testing.T) {
Subject: []byte("message"),
TreeId: git.ObjectHashSHA1.EmptyTreeOID.String(),
Author: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
Committer: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -279,7 +277,7 @@ func TestFindAllTags_duplicateAnnotatedTags(t *testing.T) {
repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
date := time.Unix(12345, 0)
dateOffset := date.Format("-0700")
@@ -306,9 +304,9 @@ func TestFindAllTags_duplicateAnnotatedTags(t *testing.T) {
}
commitAuthor := &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
}
commit := &gitalypb.GitCommit{
@@ -429,9 +427,9 @@ func TestFindAllTags_nestedTags(t *testing.T) {
Message: []byte(tagMessage),
MessageSize: int64(len([]byte(tagMessage))),
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
}
diff --git a/internal/gitaly/service/ref/list_refs_test.go b/internal/gitaly/service/ref/list_refs_test.go
index 813668ae7..dd89caaf0 100644
--- a/internal/gitaly/service/ref/list_refs_test.go
+++ b/internal/gitaly/service/ref/list_refs_test.go
@@ -21,7 +21,7 @@ func TestServer_ListRefs(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
- oldCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ oldCommitID := gittest.WriteCommit(t, cfg, repoPath)
newCommitID := gittest.WriteCommit(t, cfg, repoPath,
gittest.WithParents(oldCommitID),
gittest.WithAuthorDate(time.Date(2011, 2, 16, 14, 1, 0, 0, time.FixedZone("UTC+1", +1*60*60))),
diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go
index b4dd36197..99e4a3d6f 100644
--- a/internal/gitaly/service/ref/refs_test.go
+++ b/internal/gitaly/service/ref/refs_test.go
@@ -912,9 +912,9 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
Message: []byte("commit tag with a commit sha as the name"),
MessageSize: 40,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -925,9 +925,9 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
Message: []byte("tag of a tag"),
MessageSize: 12,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -978,9 +978,9 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
Message: []byte("Blob tag"),
MessageSize: 8,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -1010,9 +1010,9 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
MessageSize: int64(len(bigMessage)),
TargetCommit: gitCommit,
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
},
@@ -1104,9 +1104,9 @@ func TestFindTagNestedTag(t *testing.T) {
Message: []byte(tagMessage),
MessageSize: int64(len([]byte(tagMessage))),
Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Scrooge McDuck"),
- Email: []byte("scrooge@mcduck.com"),
- Date: &timestamppb.Timestamp{Seconds: 1572776879},
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(gittest.DefaultCommitTime),
Timezone: []byte("+0100"),
},
}
diff --git a/internal/gitaly/service/ref/tag_signatures_test.go b/internal/gitaly/service/ref/tag_signatures_test.go
index 6a9986758..35f91762e 100644
--- a/internal/gitaly/service/ref/tag_signatures_test.go
+++ b/internal/gitaly/service/ref/tag_signatures_test.go
@@ -4,6 +4,7 @@ package ref
import (
"errors"
+ "fmt"
"io"
"strings"
"testing"
@@ -25,16 +26,16 @@ func TestGetTagSignatures(t *testing.T) {
message1 := strings.Repeat("a", helper.MaxCommitOrTagMessageSize) + "\n"
signature1 := string(testhelper.MustReadFile(t, "testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature"))
tag1ID := gittest.WriteTag(t, cfg, repoPath, "big-tag-1", "master", gittest.WriteTagConfig{Message: message1 + signature1})
- content1 := "object 1e292f8fedd741b75372e19097c76d327140c312\ntype commit\ntag big-tag-1\ntagger Scrooge McDuck <scrooge@mcduck.com> 1572776879 +0100\n\n" + message1
+ content1 := fmt.Sprintf("object 1e292f8fedd741b75372e19097c76d327140c312\ntype commit\ntag big-tag-1\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message1)
message2 := strings.Repeat("b", helper.MaxCommitOrTagMessageSize) + "\n"
signature2 := string(testhelper.MustReadFile(t, "testdata/tag-7975be0116940bf2ad4321f79d02a55c5f7779aa-signature"))
tag2ID := gittest.WriteTag(t, cfg, repoPath, "big-tag-2", "master~", gittest.WriteTagConfig{Message: message2 + signature2})
- content2 := "object 7975be0116940bf2ad4321f79d02a55c5f7779aa\ntype commit\ntag big-tag-2\ntagger Scrooge McDuck <scrooge@mcduck.com> 1572776879 +0100\n\n" + message2
+ content2 := fmt.Sprintf("object 7975be0116940bf2ad4321f79d02a55c5f7779aa\ntype commit\ntag big-tag-2\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message2)
message3 := "tag message\n"
tag3ID := gittest.WriteTag(t, cfg, repoPath, "tag-3", "master~~", gittest.WriteTagConfig{Message: message3})
- content3 := "object 60ecb67744cb56576c30214ff52294f8ce2def98\ntype commit\ntag tag-3\ntagger Scrooge McDuck <scrooge@mcduck.com> 1572776879 +0100\n\n" + message3
+ content3 := fmt.Sprintf("object 60ecb67744cb56576c30214ff52294f8ce2def98\ntype commit\ntag tag-3\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message3)
for _, tc := range []struct {
desc string
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go
index 5b1c0cb86..a58ca9b28 100644
--- a/internal/gitaly/service/repository/create_fork_test.go
+++ b/internal/gitaly/service/repository/create_fork_test.go
@@ -117,7 +117,7 @@ func TestCreateFork_refs(t *testing.T) {
// Prepare the source repository with a bunch of refs and a non-default HEAD ref so we can
// assert that the target repo gets created with the correct set of refs.
- commitID := gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, sourceRepoPath)
for _, ref := range []string{
"refs/environments/something",
"refs/heads/something",
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index a8ede341c..939767ed0 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -40,7 +40,7 @@ func TestFetchRemote_checkTagsChanged(t *testing.T) {
_, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg)
- gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch("main"))
t.Run("check tags without tags", func(t *testing.T) {
repoProto, _ := gittest.CreateRepository(ctx, t, cfg)
@@ -814,7 +814,6 @@ func TestFetchRemote_pooledRepository(t *testing.T) {
// remote as "have".
_, poolRepoPath := gittest.CreateRepository(ctx, t, cfg)
poolCommitID := gittest.WriteCommit(t, cfg, poolRepoPath,
- gittest.WithParents(),
gittest.WithBranch("pooled"),
gittest.WithTreeEntries(gittest.TreeEntry{Path: "pool", Mode: "100644", Content: "pool contents"}),
)
@@ -829,7 +828,6 @@ func TestFetchRemote_pooledRepository(t *testing.T) {
// would actually try to fetch objects.
_, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg)
gittest.WriteCommit(t, cfg, remoteRepoPath,
- gittest.WithParents(),
gittest.WithBranch("remote"),
gittest.WithTreeEntries(gittest.TreeEntry{Path: "remote", Mode: "100644", Content: "remote contents"}),
)
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index 05184b5e5..feaeab138 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -552,7 +552,7 @@ func TestGarbageCollect_commitGraphsWithPrunedObjects(t *testing.T) {
repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg)
// Write a first commit-graph that contains the root commit, only.
- rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main"))
+ rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
gittest.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
// Write a second, incremental commit-graph that contains a commit we're about to
diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go
index 7fe42580b..bd38c746b 100644
--- a/internal/gitaly/service/repository/license_test.go
+++ b/internal/gitaly/service/repository/license_test.go
@@ -84,7 +84,7 @@ SOFTWARE.`,
})
}
- gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithTreeEntries(treeEntries...), gittest.WithParents())
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithTreeEntries(treeEntries...))
if tc.nonExistentRepository {
require.NoError(t, os.RemoveAll(repoPath))
diff --git a/internal/gitaly/service/repository/optimize_test.go b/internal/gitaly/service/repository/optimize_test.go
index 92f9bddfe..61a21499c 100644
--- a/internal/gitaly/service/repository/optimize_test.go
+++ b/internal/gitaly/service/repository/optimize_test.go
@@ -106,7 +106,6 @@ func TestOptimizeRepository(t *testing.T) {
OID: git.ObjectID(blobID), Mode: "100644", Path: "blob",
}),
gittest.WithBranch(blobID),
- gittest.WithParents(),
)
}
diff --git a/internal/gitaly/service/repository/prune_unreachable_objects_test.go b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
index d5ba20e87..29bb18eac 100644
--- a/internal/gitaly/service/repository/prune_unreachable_objects_test.go
+++ b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
@@ -59,7 +59,7 @@ func TestPruneUnreachableObjects(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
// Create the commit and a branch pointing to it to make it reachable.
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("branch"))
+ commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("branch"))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
Repository: repo,
@@ -74,7 +74,7 @@ func TestPruneUnreachableObjects(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
// Create the commit, but don't create a reference pointing to it.
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
// Set the object time to something that's close to 30 minutes, but gives us enough
// room to not cause flakes.
setObjectTime(t, repoPath, commitID, time.Now().Add(-28*time.Minute))
@@ -93,7 +93,7 @@ func TestPruneUnreachableObjects(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
// Create the commit, but don't create a reference pointing to it.
- commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
setObjectTime(t, repoPath, commitID, time.Now().Add(-31*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
@@ -110,13 +110,13 @@ func TestPruneUnreachableObjects(t *testing.T) {
t.Run("repository with mixed objects", func(t *testing.T) {
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
- reachableOldCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithMessage("a"), gittest.WithBranch("branch"))
+ reachableOldCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("a"), gittest.WithBranch("branch"))
setObjectTime(t, repoPath, reachableOldCommit, time.Now().Add(-31*time.Minute))
- unreachableRecentCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("b"), gittest.WithParents())
+ unreachableRecentCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("b"))
setObjectTime(t, repoPath, unreachableRecentCommit, time.Now().Add(-28*time.Minute))
- unreachableOldCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("c"), gittest.WithParents())
+ unreachableOldCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("c"))
setObjectTime(t, repoPath, unreachableOldCommit, time.Now().Add(-31*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
@@ -141,7 +141,7 @@ func TestPruneUnreachableObjects(t *testing.T) {
// Write two commits into the repository and create a commit-graph. The second
// commit will become unreachable and will be pruned, but will be contained in the
// commit-graph.
- rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents())
+ rootCommitID := gittest.WriteCommit(t, cfg, repoPath)
unreachableCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(rootCommitID), gittest.WithBranch("main"))
gittest.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
diff --git a/internal/gitaly/service/repository/rename_test.go b/internal/gitaly/service/repository/rename_test.go
index a394f0798..cf7267308 100644
--- a/internal/gitaly/service/repository/rename_test.go
+++ b/internal/gitaly/service/repository/rename_test.go
@@ -67,7 +67,7 @@ func testRenameRepositoryDestinationExists(t *testing.T, ctx context.Context) {
require.NoError(t, err)
destinationRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, existingDestinationRepo))
- commitID := gittest.WriteCommit(t, cfg, destinationRepoPath, gittest.WithParents())
+ commitID := gittest.WriteCommit(t, cfg, destinationRepoPath)
_, err = client.RenameRepository(ctx, &gitalypb.RenameRepositoryRequest{
Repository: renamedRepo,
diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go
index 0f3da43dc..02ca6296e 100644
--- a/internal/gitaly/service/smarthttp/upload_pack_test.go
+++ b/internal/gitaly/service/smarthttp/upload_pack_test.go
@@ -139,7 +139,6 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context,
// the gitconfig indeed is applied because we should not be able to fetch the hidden ref.
baseID := gittest.WriteCommit(t, cfg, repoPath,
gittest.WithMessage("base commit"),
- gittest.WithParents(),
gittest.WithBranch("main"),
)
hiddenID := gittest.WriteCommit(t, cfg, repoPath,
diff --git a/internal/gitaly/service/wiki/find_page_test.go b/internal/gitaly/service/wiki/find_page_test.go
index 482337281..b1e59e295 100644
--- a/internal/gitaly/service/wiki/find_page_test.go
+++ b/internal/gitaly/service/wiki/find_page_test.go
@@ -469,7 +469,6 @@ func testSuccessfulWikiFindPageRequestWithTrailers(t *testing.T, cfg config.Cfg,
gittest.WriteCommit(t, cfg, repoPath,
gittest.WithBranch("main"),
- gittest.WithParents(),
gittest.WithMessage("main branch, empty commit"),
)