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>2023-08-18 14:38:15 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-18 14:38:15 +0300
commit0183d30e998cfab0b4f93fd1aa60200fba8e3771 (patch)
tree979c0d258ee07751cca078e60e2761e1a2283175
parent3735c107042fc9eed44bda1dc600684ee16a1c92 (diff)
parente053dfc659f52f5445c50cabb56600bb207c4d01 (diff)
Merge branch 'pks-ref-sha256-pt2' into 'master'
ref: Convert remaining tests to test with SHA256 object format Closes #5439 See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6225 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Approved-by: karthik nayak <knayak@gitlab.com>
-rw-r--r--internal/git/gittest/tag.go14
-rw-r--r--internal/gitaly/service/ref/branches_test.go4
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go8
-rw-r--r--internal/gitaly/service/ref/find_all_branches_test.go2
-rw-r--r--internal/gitaly/service/ref/find_all_remote_branches.go (renamed from internal/gitaly/service/ref/remote_branches.go)0
-rw-r--r--internal/gitaly/service/ref/find_all_remote_branches_test.go168
-rw-r--r--internal/gitaly/service/ref/find_all_tags_test.go1303
-rw-r--r--internal/gitaly/service/ref/find_default_branch_name_test.go2
-rw-r--r--internal/gitaly/service/ref/find_local_branches_test.go2
-rw-r--r--internal/gitaly/service/ref/find_refs_by_oid_test.go6
-rw-r--r--internal/gitaly/service/ref/find_tag_test.go2
-rw-r--r--internal/gitaly/service/ref/list_refs_test.go4
-rw-r--r--internal/gitaly/service/ref/refexists_test.go2
-rw-r--r--internal/gitaly/service/ref/refnames_containing_test.go4
-rw-r--r--internal/gitaly/service/ref/remote_branches_test.go142
-rw-r--r--internal/gitaly/service/ref/tag_messages_test.go4
-rw-r--r--internal/gitaly/service/ref/tag_signatures_test.go95
-rw-r--r--internal/gitaly/service/ref/testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature6
-rw-r--r--internal/gitaly/service/ref/testdata/tag-7975be0116940bf2ad4321f79d02a55c5f7779aa-signature101
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go10
-rw-r--r--internal/gitaly/service/ref/update_references_test.go2
21 files changed, 917 insertions, 964 deletions
diff --git a/internal/git/gittest/tag.go b/internal/git/gittest/tag.go
index 27383506a..1c3dd2d0b 100644
--- a/internal/git/gittest/tag.go
+++ b/internal/git/gittest/tag.go
@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"testing"
+ "time"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
@@ -18,6 +19,9 @@ type WriteTagConfig struct {
Message string
// Force indicates whether existing tags with the same name shall be overwritten.
Force bool
+ // Date modifies the committer date that the tag should have. This only has an effect when writing
+ // annotated tags.
+ Date time.Time
}
// WriteTag writes a new tag into the repository. This function either returns the tag ID in case
@@ -59,7 +63,15 @@ func WriteTag(
}
args = append(args, tagName, targetRevision.String())
- ExecOpts(tb, cfg, ExecConfig{Stdin: stdin}, args...)
+ var env []string
+ if !config.Date.IsZero() {
+ env = append(env, fmt.Sprintf("GIT_COMMITTER_DATE=%d %s", config.Date.Unix(), config.Date.Format("-0700")))
+ }
+
+ ExecOpts(tb, cfg, ExecConfig{
+ Stdin: stdin,
+ Env: env,
+ }, args...)
tagID := Exec(tb, cfg, "-C", repoPath, "show-ref", "-s", tagName)
diff --git a/internal/gitaly/service/ref/branches_test.go b/internal/gitaly/service/ref/branches_test.go
index 9b7ef3565..393e44552 100644
--- a/internal/gitaly/service/ref/branches_test.go
+++ b/internal/gitaly/service/ref/branches_test.go
@@ -19,7 +19,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
@@ -86,7 +86,7 @@ func TestFailedFindBranchRequest(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, _ := gittest.CreateRepository(t, ctx, cfg)
testCases := []struct {
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index b5f085fb5..48c12eb82 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -29,7 +29,7 @@ func TestDeleteRefs_successful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
testCases := []struct {
desc string
@@ -183,7 +183,7 @@ func TestDeleteRefs_invalidRefFormat(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, _ := gittest.CreateRepository(t, ctx, cfg)
request := &gitalypb.DeleteRefsRequest{
@@ -210,7 +210,7 @@ func TestDeleteRefs_refLocked(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg)
oldValue := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("master"))
@@ -254,7 +254,7 @@ func TestDeleteRefs_validation(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, _ := gittest.CreateRepository(t, ctx, cfg)
testCases := []struct {
diff --git a/internal/gitaly/service/ref/find_all_branches_test.go b/internal/gitaly/service/ref/find_all_branches_test.go
index 061695302..d0950ed7d 100644
--- a/internal/gitaly/service/ref/find_all_branches_test.go
+++ b/internal/gitaly/service/ref/find_all_branches_test.go
@@ -17,7 +17,7 @@ func TestFindAllBranches(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
type setupData struct {
request *gitalypb.FindAllBranchesRequest
diff --git a/internal/gitaly/service/ref/remote_branches.go b/internal/gitaly/service/ref/find_all_remote_branches.go
index 464d1c234..464d1c234 100644
--- a/internal/gitaly/service/ref/remote_branches.go
+++ b/internal/gitaly/service/ref/find_all_remote_branches.go
diff --git a/internal/gitaly/service/ref/find_all_remote_branches_test.go b/internal/gitaly/service/ref/find_all_remote_branches_test.go
new file mode 100644
index 000000000..85790388d
--- /dev/null
+++ b/internal/gitaly/service/ref/find_all_remote_branches_test.go
@@ -0,0 +1,168 @@
+package ref
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
+)
+
+func TestFindAllRemoteBranches(t *testing.T) {
+ t.Parallel()
+
+ ctx := testhelper.Context(t)
+ cfg, client := setupRefService(t)
+
+ type setupData struct {
+ request *gitalypb.FindAllRemoteBranchesRequest
+ expectedErr error
+ expectedBranches []*gitalypb.Branch
+ }
+
+ for _, tc := range []struct {
+ desc string
+ setup func(t *testing.T) setupData
+ }{
+ {
+ desc: "unknown storage",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: &gitalypb.Repository{
+ StorageName: "fake",
+ RelativePath: "repo",
+ },
+ RemoteName: "stub",
+ },
+ expectedErr: testhelper.ToInterceptedMetadata(structerr.NewInvalidArgument(
+ "%w", storage.NewStorageNotFoundError("fake"),
+ )),
+ }
+ },
+ },
+ {
+ desc: "unset repository",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ RemoteName: "myRemote",
+ },
+ expectedErr: structerr.NewInvalidArgument("%w", storage.ErrRepositoryNotSet),
+ }
+ },
+ },
+ {
+ desc: "unset remote name",
+ setup: func(t *testing.T) setupData {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: repo,
+ },
+ expectedErr: structerr.NewInvalidArgument("empty RemoteName"),
+ }
+ },
+ },
+ {
+ desc: "empty repository",
+ setup: func(t *testing.T) setupData {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: repo,
+ RemoteName: "origin",
+ },
+ }
+ },
+ },
+ {
+ desc: "no remote branches",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
+ for _, ref := range []git.ReferenceName{
+ "refs/heads/branch",
+ "refs/tags/tag",
+ "refs/something",
+ "refs/keep-around/keep-around",
+ } {
+ gittest.WriteRef(t, cfg, repoPath, ref, commitID)
+ }
+
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: repo,
+ RemoteName: "origin",
+ },
+ }
+ },
+ },
+ {
+ desc: "different remote",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithReference("refs/remotes/origin/branch"))
+
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: repo,
+ RemoteName: "does-not-exist",
+ },
+ }
+ },
+ },
+ {
+ desc: "mixed requested and unrequested remote references",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commit1ID, commit1 := writeCommit(t, ctx, cfg, repo, gittest.WithMessage("commit 1"))
+ gittest.WriteRef(t, cfg, repoPath, "refs/remotes/origin/branch-1", commit1ID)
+ gittest.WriteRef(t, cfg, repoPath, "refs/remotes/unrelated/branch-1", commit1ID)
+
+ commit2ID, commit2 := writeCommit(t, ctx, cfg, repo, gittest.WithMessage("commit 2"))
+ gittest.WriteRef(t, cfg, repoPath, "refs/remotes/origin/branch-2", commit2ID)
+ gittest.WriteRef(t, cfg, repoPath, "refs/remotes/unrelated/branch-2", commit2ID)
+
+ return setupData{
+ request: &gitalypb.FindAllRemoteBranchesRequest{
+ Repository: repo,
+ RemoteName: "origin",
+ },
+ expectedBranches: []*gitalypb.Branch{
+ {Name: []byte("refs/remotes/origin/branch-1"), TargetCommit: commit1},
+ {Name: []byte("refs/remotes/origin/branch-2"), TargetCommit: commit2},
+ },
+ }
+ },
+ },
+ } {
+ tc := tc
+
+ t.Run(tc.desc, func(t *testing.T) {
+ t.Parallel()
+
+ setup := tc.setup(t)
+
+ stream, err := client.FindAllRemoteBranches(ctx, setup.request)
+ require.NoError(t, err)
+
+ branches, err := testhelper.ReceiveAndFold(stream.Recv, func(
+ result []*gitalypb.Branch,
+ response *gitalypb.FindAllRemoteBranchesResponse,
+ ) []*gitalypb.Branch {
+ return append(result, response.GetBranches()...)
+ })
+ testhelper.RequireGrpcError(t, setup.expectedErr, err)
+ testhelper.ProtoEqual(t, setup.expectedBranches, branches)
+ })
+ }
+}
diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go
index f08ec4d6d..cfae77c17 100644
--- a/internal/gitaly/service/ref/find_all_tags_test.go
+++ b/internal/gitaly/service/ref/find_all_tags_test.go
@@ -1,9 +1,6 @@
-//go:build !gitaly_test_sha256
-
package ref
import (
- "bytes"
"context"
"fmt"
"io"
@@ -13,672 +10,691 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)
-func TestFindAllTags_successful(t *testing.T) {
- ctx := testhelper.Context(t)
- cfg, repoProto, repoPath, client := setupRefService(t, ctx)
- repo := localrepo.NewTestRepo(t, cfg, repoProto)
-
- // reconstruct the v1.1.2 tag from patches to test truncated tag message
- // with partial PGP block
- truncatedPGPTagMsg := testhelper.MustReadFile(t, "testdata/truncated_pgp_msg.patch")
-
- truncatedPGPTagID := text.ChompBytes(gittest.ExecOpts(t, cfg, gittest.ExecConfig{Stdin: bytes.NewBuffer(truncatedPGPTagMsg)},
- "-C", repoPath, "mktag",
- ))
- gittest.Exec(t, cfg, "-C", repoPath, "update-ref", "refs/tags/pgp-long-tag-message", truncatedPGPTagID)
-
- blobID := git.ObjectID("faaf198af3a36dbf41961466703cc1d47c61d051")
- commitID := git.ObjectID("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9")
-
- gitCommit := testhelper.GitLabTestCommit(commitID.String())
-
- bigCommitID := gittest.WriteCommit(t, cfg, repoPath,
- gittest.WithBranch("local-big-commits"),
- gittest.WithMessage("An empty commit with REALLY BIG message\n\n"+strings.Repeat("a", helper.MaxCommitOrTagMessageSize+1)),
- gittest.WithParents("60ecb67744cb56576c30214ff52294f8ce2def98"),
- )
- bigCommit, err := repo.ReadCommit(ctx, git.Revision(bigCommitID))
- require.NoError(t, err)
-
- annotatedTagID := gittest.WriteTag(t, cfg, repoPath, "v1.2.0", blobID.Revision(), gittest.WriteTagConfig{Message: "Blob tag"})
-
- gittest.WriteTag(t, cfg, repoPath, "v1.3.0", commitID.Revision())
- gittest.WriteTag(t, cfg, repoPath, "v1.4.0", blobID.Revision())
-
- // To test recursive resolving to a commit
- gittest.WriteTag(t, cfg, repoPath, "v1.5.0", "v1.3.0")
-
- // A tag to commit with a big message
- gittest.WriteTag(t, cfg, repoPath, "v1.6.0", bigCommitID.Revision())
-
- // A tag with a big message
- bigMessage := strings.Repeat("a", 11*1024)
- bigMessageTag1ID := gittest.WriteTag(t, cfg, repoPath, "v1.7.0", commitID.Revision(), gittest.WriteTagConfig{Message: bigMessage})
-
- // A tag with a commit id as its name
- commitTagID := gittest.WriteTag(t, cfg, repoPath, commitID.String(), commitID.Revision(), gittest.WriteTagConfig{Message: "commit tag with a commit sha as the name"})
-
- // a tag of a tag
- tagOfTagID := gittest.WriteTag(t, cfg, repoPath, "tag-of-tag", commitTagID.Revision(), gittest.WriteTagConfig{Message: "tag of a tag"})
+func TestFindAllTags(t *testing.T) {
+ t.Parallel()
- rpcRequest := &gitalypb.FindAllTagsRequest{Repository: repoProto}
+ ctx := testhelper.Context(t)
+ cfg, client := setupRefService(t)
- c, err := client.FindAllTags(ctx, rpcRequest)
- require.NoError(t, err)
+ sortSetup := setupSortRepository(t, ctx, cfg)
- var receivedTags []*gitalypb.Tag
- for {
- r, err := c.Recv()
- if err == io.EOF {
- break
- }
- require.NoError(t, err)
- receivedTags = append(receivedTags, r.GetTags()...)
+ type setupData struct {
+ request *gitalypb.FindAllTagsRequest
+ expectedErr error
+ expectedTags []*gitalypb.Tag
}
- expectedTags := []*gitalypb.Tag{
- {
- Name: []byte(commitID),
- Id: commitTagID.String(),
- TargetCommit: gitCommit,
- Message: []byte("commit tag with a commit sha as the name"),
- MessageSize: 40,
- Tagger: gittest.DefaultCommitAuthor,
- },
- {
- Name: []byte("tag-of-tag"),
- Id: tagOfTagID.String(),
- TargetCommit: gitCommit,
- Message: []byte("tag of a tag"),
- MessageSize: 12,
- Tagger: gittest.DefaultCommitAuthor,
- },
+ for _, tc := range []struct {
+ desc string
+ setup func(t *testing.T) setupData
+ }{
{
- Name: []byte("v1.0.0"),
- Id: "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- TargetCommit: gitCommit,
- Message: []byte("Release"),
- MessageSize: 7,
- Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Dmitriy Zaporozhets"),
- Email: []byte("dmitriy.zaporozhets@gmail.com"),
- Date: &timestamppb.Timestamp{Seconds: 1393491299},
- Timezone: []byte("+0200"),
+ desc: "unset repository",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{},
+ expectedErr: structerr.NewInvalidArgument("%w", storage.ErrRepositoryNotSet),
+ }
},
},
{
- Name: []byte("v1.1.0"),
- Id: "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- TargetCommit: testhelper.GitLabTestCommit("5937ac0a7beb003549fc5fd26fc247adbce4a52e"),
- Message: []byte("Version 1.1.0"),
- MessageSize: 13,
- Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Dmitriy Zaporozhets"),
- Email: []byte("dmitriy.zaporozhets@gmail.com"),
- Date: &timestamppb.Timestamp{Seconds: 1393505709},
- Timezone: []byte("+0200"),
+ desc: "unknown storage",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: &gitalypb.Repository{
+ StorageName: "fake",
+ RelativePath: "repo",
+ },
+ },
+ expectedErr: testhelper.ToInterceptedMetadata(structerr.NewInvalidArgument(
+ "%w", storage.NewStorageNotFoundError("fake"),
+ )),
+ }
},
},
{
- Name: []byte("v1.1.1"),
- Id: "8f03acbcd11c53d9c9468078f32a2622005a4841",
- TargetCommit: testhelper.GitLabTestCommit("189a6c924013fc3fe40d6f1ec1dc20214183bc97"),
- Message: []byte("x509 signed tag\n-----BEGIN SIGNED MESSAGE-----\nMIISfwYJKoZIhvcNAQcCoIIScDCCEmwCAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIP8zCCB3QwggVcoAMCAQICBBXXLOIwDQYJKoZIhvcNAQELBQAwgbYx\nCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCYXllcm4xETAPBgNVBAcMCE11ZW5jaGVu\nMRAwDgYDVQQKDAdTaWVtZW5zMREwDwYDVQQFEwhaWlpaWlpBNjEdMBsGA1UECwwU\nU2llbWVucyBUcnVzdCBDZW50ZXIxPzA9BgNVBAMMNlNpZW1lbnMgSXNzdWluZyBD\nQSBNZWRpdW0gU3RyZW5ndGggQXV0aGVudGljYXRpb24gMjAxNjAeFw0xNzAyMDMw\nNjU4MzNaFw0yMDAyMDMwNjU4MzNaMFsxETAPBgNVBAUTCFowMDBOV0RIMQ4wDAYD\nVQQqDAVSb2dlcjEOMAwGA1UEBAwFTWVpZXIxEDAOBgNVBAoMB1NpZW1lbnMxFDAS\nBgNVBAMMC01laWVyIFJvZ2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\nAQEAuBNea/68ZCnHYQjpm/k3ZBG0wBpEKSwG6lk9CEQlSxsqVLQHAoAKBIlJm1in\nYVLcK/Sq1yhYJ/qWcY/M53DhK2rpPuhtrWJUdOUy8EBWO20F4bd4Fw9pO7jt8bme\nu33TSrK772vKjuppzB6SeG13Cs08H+BIeD106G27h7ufsO00pvsxoSDL+uc4slnr\npBL+2TAL7nSFnB9QHWmRIK27SPqJE+lESdb0pse11x1wjvqKy2Q7EjL9fpqJdHzX\nNLKHXd2r024TOORTa05DFTNR+kQEKKV96XfpYdtSBomXNQ44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S\nLVWlkgrmedXdLmuBzAGEaaZOJS0lEpNd01pR/reHs7xxZ+RZ0olTs2ufM0CijQSx\nOL9HDl2O3OoD77NWx4tl3Wy1yJCeV3XH/cEI7AkKHCmKY9QMoMYWh16ORBtr+YcS\nYK+gONOjpjgcgTJgZ3HSFgQ50xiD4WT1kFBHsuYsLqaOSbTfTN6Ayyg4edjrPQqa\nVcVf1OQcIrfWA3yMQrnEZfOYfN/D4EPjTfxBV+VCi/F2bdZmMbJ7jNk1FbewSwWO\nSDH1i0K32NyFbnh0BSos7njq7ELqKlYBsoB/sZfaH2vKy5U=\n-----END SIGNED MESSAGE-----"),
- MessageSize: 6494,
- Tagger: &gitalypb.CommitAuthor{
- Name: []byte("Roger Meier"),
- Email: []byte("r.meier@siemens.com"),
- Date: &timestamppb.Timestamp{Seconds: 1574261780},
- Timezone: []byte("+0100"),
+ desc: "unsupported sorting key",
+ setup: func(t *testing.T) setupData {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_Key(-1),
+ },
+ },
+ expectedErr: structerr.NewInvalidArgument("unsupported sorting key: -1"),
+ }
},
- SignatureType: gitalypb.SignatureType_X509,
},
{
- Name: []byte("pgp-long-tag-message"),
- Id: truncatedPGPTagID,
- TargetCommit: gitCommit, // 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
- Message: truncatedPGPTagMsg[146:10386], // first 10240 bytes of tag message
- MessageSize: 11148,
- Tagger: &gitalypb.CommitAuthor{
- Name: []byte(gittest.DefaultCommitterName),
- Email: []byte(gittest.DefaultCommitterMail),
- Date: &timestamppb.Timestamp{Seconds: 1393491261},
- Timezone: []byte("+0100"),
+ desc: "unsupported sorting direction",
+ setup: func(t *testing.T) setupData {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME,
+ Direction: gitalypb.SortDirection(-1),
+ },
+ },
+ expectedErr: structerr.NewInvalidArgument("unsupported sorting direction: -1"),
+ }
},
- SignatureType: gitalypb.SignatureType_PGP,
- },
- {
- Name: []byte("v1.2.0"),
- Id: annotatedTagID.String(),
- Message: []byte("Blob tag"),
- MessageSize: 8,
- Tagger: gittest.DefaultCommitAuthor,
},
{
- Name: []byte("v1.3.0"),
- Id: commitID.String(),
- TargetCommit: gitCommit,
+ desc: "no tags",
+ setup: func(t *testing.T) setupData {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ }
+ },
},
{
- Name: []byte("v1.4.0"),
- Id: blobID.String(),
+ desc: "lightweight tag",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ tagID := gittest.WriteTag(t, cfg, repoPath, commitID.String(), commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte(commitID),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
+ },
},
{
- Name: []byte("v1.5.0"),
- Id: commitID.String(),
- TargetCommit: gitCommit,
+ desc: "annotated tag",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ tagID := gittest.WriteTag(t, cfg, repoPath, commitID.String(), commitID.Revision(), gittest.WriteTagConfig{
+ Message: "annotated",
+ })
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte(commitID),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ Message: []byte("annotated"),
+ MessageSize: 9,
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ },
+ }
+ },
},
{
- Name: []byte("v1.6.0"),
- Id: bigCommitID.String(),
- TargetCommit: bigCommit,
+ desc: "tag pointing to blob",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ blobID := gittest.WriteBlob(t, cfg, repoPath, []byte("tagged data"))
+ tagID := gittest.WriteTag(t, cfg, repoPath, "tagged-blob", blobID.Revision(), gittest.WriteTagConfig{
+ Message: "annotated",
+ })
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("tagged-blob"),
+ Id: tagID.String(),
+ Message: []byte("annotated"),
+ MessageSize: 9,
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ },
+ }
+ },
},
{
- Name: []byte("v1.7.0"),
- Id: bigMessageTag1ID.String(),
- Message: []byte(bigMessage[:helper.MaxCommitOrTagMessageSize]),
- MessageSize: int64(len(bigMessage)),
- TargetCommit: gitCommit,
- Tagger: gittest.DefaultCommitAuthor,
- },
- }
-
- require.Len(t, receivedTags, len(expectedTags))
- require.ElementsMatch(t, expectedTags, receivedTags)
-}
-
-func TestFindAllTags_simpleNestedTags(t *testing.T) {
- t.Parallel()
-
- cfg, client := setupRefServiceWithoutRepo(t)
- ctx := testhelper.Context(t)
+ desc: "deeply nested tag",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+
+ currentID := commitID
+ var expectedTags []*gitalypb.Tag
+ for i := 0; i < 20; i++ {
+ tagName := fmt.Sprintf("tag-%02d", i)
+
+ currentID = gittest.WriteTag(t, cfg, repoPath, tagName, currentID.Revision(), gittest.WriteTagConfig{
+ Message: tagName,
+ })
+
+ expectedTags = append(expectedTags, &gitalypb.Tag{
+ Name: []byte(tagName),
+ Id: currentID.String(),
+ TargetCommit: commit,
+ Message: []byte(tagName),
+ MessageSize: 6,
+ Tagger: gittest.DefaultCommitAuthor,
+ })
+ }
- repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg)
-
- commitID := gittest.WriteCommit(t, cfg, repoPath)
-
- tagID := gittest.WriteTag(t, cfg, repoPath, "my/nested/tag", commitID.Revision())
-
- stream, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{Repository: repoProto})
- require.NoError(t, err)
-
- response, err := stream.Recv()
- require.NoError(t, err)
- testhelper.ProtoEqual(t, &gitalypb.FindAllTagsResponse{
- Tags: []*gitalypb.Tag{
- {
- Name: []byte("my/nested/tag"),
- Id: tagID.String(),
- TargetCommit: &gitalypb.GitCommit{
- Id: commitID.String(),
- Body: []byte("message"),
- BodySize: 7,
- Subject: []byte("message"),
- TreeId: git.ObjectHashSHA1.EmptyTreeOID.String(),
- Author: gittest.DefaultCommitAuthor,
- Committer: gittest.DefaultCommitAuthor,
- },
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: expectedTags,
+ }
},
},
- }, response)
-
- response, err = stream.Recv()
- require.Equal(t, io.EOF, err)
- require.Nil(t, response)
-}
-
-func TestFindAllTags_duplicateAnnotatedTags(t *testing.T) {
- t.Parallel()
-
- cfg, client := setupRefServiceWithoutRepo(t)
- ctx := testhelper.Context(t)
-
- repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg)
- repo := localrepo.NewTestRepo(t, cfg, repoProto)
-
- commitID := gittest.WriteCommit(t, cfg, repoPath)
- date := time.Unix(12345, 0)
- dateOffset := date.Format("-0700")
-
- tagID, err := repo.WriteTag(ctx, commitID, "commit", []byte("annotated"), []byte("message"),
- gittest.TestUser, date)
- require.NoError(t, err)
-
- require.NoError(t, repo.UpdateRef(ctx, "refs/tags/annotated", tagID, git.ObjectHashSHA1.ZeroOID))
- require.NoError(t, repo.UpdateRef(ctx, "refs/tags/annotated-dup", tagID, git.ObjectHashSHA1.ZeroOID))
- require.NoError(t, repo.UpdateRef(ctx, "refs/tags/lightweight-1", commitID, git.ObjectHashSHA1.ZeroOID))
- require.NoError(t, repo.UpdateRef(ctx, "refs/tags/lightweight-2", commitID, git.ObjectHashSHA1.ZeroOID))
-
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{Repository: repoProto})
- require.NoError(t, err)
-
- var receivedTags []*gitalypb.Tag
- for {
- r, err := c.Recv()
- if err == io.EOF {
- break
- }
- require.NoError(t, err)
- receivedTags = append(receivedTags, r.GetTags()...)
- }
-
- commit := &gitalypb.GitCommit{
- Id: commitID.String(),
- TreeId: "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
- Body: []byte("message"),
- BodySize: 7,
- Subject: []byte("message"),
- Author: gittest.DefaultCommitAuthor,
- Committer: gittest.DefaultCommitAuthor,
- }
-
- testhelper.ProtoEqual(t, []*gitalypb.Tag{
{
- Name: []byte("annotated"),
- Id: tagID.String(),
- Message: []byte("message"),
- MessageSize: 7,
- Tagger: &gitalypb.CommitAuthor{
- Name: gittest.TestUser.Name,
- Email: gittest.TestUser.Email,
- Date: timestamppb.New(date),
- Timezone: []byte(dateOffset),
+ desc: "tag with commit ID as name",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ tagID := gittest.WriteTag(t, cfg, repoPath, commitID.String(), commitID.Revision(), gittest.WriteTagConfig{
+ Message: "message\n",
+ })
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte(commitID),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ Message: []byte("message"),
+ MessageSize: 7,
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ },
+ }
},
- TargetCommit: commit,
},
{
- Name: []byte("annotated-dup"),
- Id: tagID.String(),
- Message: []byte("message"),
- MessageSize: 7,
- Tagger: &gitalypb.CommitAuthor{
- Name: gittest.TestUser.Name,
- Email: gittest.TestUser.Email,
- Date: timestamppb.New(date),
- Timezone: []byte(dateOffset),
+ desc: "tag of tag",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ parentTagID := gittest.WriteTag(t, cfg, repoPath, "parent-tag", commitID.Revision(), gittest.WriteTagConfig{
+ Message: "parent message\n",
+ })
+ childTagID := gittest.WriteTag(t, cfg, repoPath, "child-tag", parentTagID.Revision(), gittest.WriteTagConfig{
+ Message: "child message\n",
+ })
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("child-tag"),
+ Id: childTagID.String(),
+ TargetCommit: commit,
+ Message: []byte("child message"),
+ MessageSize: 13,
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ {
+ Name: []byte("parent-tag"),
+ Id: parentTagID.String(),
+ TargetCommit: commit,
+ Message: []byte("parent message"),
+ MessageSize: 14,
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ },
+ }
},
- TargetCommit: commit,
- },
- {Name: []byte("lightweight-1"), Id: commitID.String(), TargetCommit: commit},
- {Name: []byte("lightweight-2"), Id: commitID.String(), TargetCommit: commit},
- }, receivedTags)
-}
-
-func TestFindAllTags_nestedTags(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
- cfg, repoProto, repoPath, client := setupRefService(t, ctx)
-
- repo := localrepo.NewTestRepo(t, cfg, repoProto)
-
- blobID := git.ObjectID("faaf198af3a36dbf41961466703cc1d47c61d051")
- commitID := git.ObjectID("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9")
-
- testCases := []struct {
- description string
- depth int
- originalOid git.ObjectID
- }{
- {
- description: "nested 1 deep, points to a commit",
- depth: 1,
- originalOid: commitID,
},
{
- description: "nested 4 deep, points to a commit",
- depth: 4,
- originalOid: commitID,
+ desc: "tag of commit with huge commit message",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitMessage := "An empty commit with REALLY BIG message\n\n" + strings.Repeat("a", helper.MaxCommitOrTagMessageSize+1)
+ commitID, commit := writeCommit(t, ctx, cfg, repo,
+ gittest.WithMessage(commitMessage),
+ )
+ tagID := gittest.WriteTag(t, cfg, repoPath, "tag", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("tag"),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
+ },
},
{
- description: "nested 3 deep, points to a blob",
- depth: 3,
- originalOid: blobID,
+ desc: "tag with huge tag message",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ tagMessage := strings.Repeat("a", 11*1024)
+ tagID := gittest.WriteTag(t, cfg, repoPath, "tag", commitID.Revision(), gittest.WriteTagConfig{
+ Message: tagMessage,
+ })
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("tag"),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ Message: []byte(tagMessage[:helper.MaxCommitOrTagMessageSize]),
+ MessageSize: int64(len(tagMessage)),
+ Tagger: gittest.DefaultCommitAuthor,
+ },
+ },
+ }
+ },
},
{
- description: "nested 20 deep, points to a commit",
- depth: 20,
- originalOid: commitID,
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.description, func(t *testing.T) {
- tags, err := repo.GetReferences(ctx, "refs/tags/")
- require.NoError(t, err)
-
- updater, err := updateref.New(ctx, repo)
- require.NoError(t, err)
- defer testhelper.MustClose(t, updater)
-
- require.NoError(t, updater.Start())
- for _, tag := range tags {
- require.NoError(t, updater.Delete(tag.Name))
- }
- require.NoError(t, updater.Commit())
-
- catfileCache := catfile.NewCache(cfg)
- defer catfileCache.Stop()
-
- objectReader, cancel, err := catfileCache.ObjectReader(ctx, repo)
- require.NoError(t, err)
- defer cancel()
-
- objectInfoReader, cancel, err := catfileCache.ObjectInfoReader(ctx, repo)
- require.NoError(t, err)
- defer cancel()
-
- info, err := objectInfoReader.Info(ctx, git.Revision(tc.originalOid))
- require.NoError(t, err)
-
- expectedTags := make(map[string]*gitalypb.Tag)
- tagID := tc.originalOid
-
- for depth := 0; depth < tc.depth; depth++ {
- tagName := fmt.Sprintf("tag-depth-%d", depth)
- tagMessage := fmt.Sprintf("a commit %d deep", depth)
- tagID = gittest.WriteTag(t, cfg, repoPath, tagName, tagID.Revision(), gittest.WriteTagConfig{Message: tagMessage})
-
- expectedTag := &gitalypb.Tag{
- Name: []byte(tagName),
- Id: tagID.String(),
- Message: []byte(tagMessage),
- MessageSize: int64(len([]byte(tagMessage))),
- Tagger: gittest.DefaultCommitAuthor,
- }
-
- if info.Type == "commit" {
- commit, err := catfile.GetCommit(ctx, objectReader, git.Revision(tc.originalOid))
- require.NoError(t, err)
- expectedTag.TargetCommit = commit
- }
-
- expectedTags[string(expectedTag.Name)] = expectedTag
- }
-
- rpcRequest := &gitalypb.FindAllTagsRequest{Repository: repoProto}
-
- c, err := client.FindAllTags(ctx, rpcRequest)
- require.NoError(t, err)
-
- var receivedTags []*gitalypb.Tag
- for {
- r, err := c.Recv()
- if err == io.EOF {
- break
- }
+ desc: "tag with signature",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ output := gittest.ExecOpts(t, cfg, gittest.ExecConfig{
+ Stdin: strings.NewReader(fmt.Sprintf(
+ `object %[1]s
+type commit
+tag signed-tag
+tagger Some Author <some.author@example.com> 100000000 +0100
+gpgsig -----BEGIN PGP SIGNATURE-----
+ this is a pseude PGP signature
+ -----END PGP SIGNATURE-----
+
+signed tag message
+`, commitID)),
+ }, "-C", repoPath, "hash-object", "-t", "tag", "--stdin", "-w")
+ tagID, err := gittest.DefaultObjectHash.FromHex(text.ChompBytes(output))
require.NoError(t, err)
- receivedTags = append(receivedTags, r.GetTags()...)
- }
-
- require.Len(t, receivedTags, len(expectedTags))
- for _, receivedTag := range receivedTags {
- testhelper.ProtoEqual(t, expectedTags[string(receivedTag.Name)], receivedTag)
- }
- })
- }
-}
-
-func TestFindAllTags_invalidRequest(t *testing.T) {
- t.Parallel()
-
- _, client := setupRefServiceWithoutRepo(t)
- ctx := testhelper.Context(t)
-
- testCases := []struct {
- desc string
- request *gitalypb.FindAllTagsRequest
- expectedErr error
- }{
- {
- desc: "empty request",
- request: &gitalypb.FindAllTagsRequest{},
- expectedErr: structerr.NewInvalidArgument("%w", storage.ErrRepositoryNotSet),
+ gittest.WriteRef(t, cfg, repoPath, "refs/tags/signed-tag", tagID)
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("signed-tag"),
+ Id: tagID.String(),
+ TargetCommit: commit,
+ Message: []byte("signed tag message"),
+ MessageSize: 18,
+ Tagger: &gitalypb.CommitAuthor{
+ Name: []byte("Some Author"),
+ Email: []byte("some.author@example.com"),
+ Timezone: []byte("+0100"),
+ Date: timestamppb.New(time.Unix(100000000, 0)),
+ },
+ },
+ },
+ }
+ },
},
{
- desc: "invalid repo",
- request: &gitalypb.FindAllTagsRequest{
- Repository: &gitalypb.Repository{
- StorageName: "fake",
- RelativePath: "repo",
- },
+ desc: "duplicated tags",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ tagID := gittest.WriteTag(t, cfg, repoPath, "annotated", commitID.Revision(), gittest.WriteTagConfig{
+ Message: "annotated tag message",
+ })
+ gittest.WriteRef(t, cfg, repoPath, "refs/tags/annotated-dup", tagID)
+ gittest.WriteRef(t, cfg, repoPath, "refs/tags/lightweight-1", commitID)
+ gittest.WriteRef(t, cfg, repoPath, "refs/tags/lightweight-2", commitID)
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("annotated"),
+ Id: tagID.String(),
+ Message: []byte("annotated tag message"),
+ MessageSize: 21,
+ Tagger: gittest.DefaultCommitAuthor,
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("annotated-dup"),
+ Id: tagID.String(),
+ Message: []byte("annotated tag message"),
+ MessageSize: 21,
+ Tagger: gittest.DefaultCommitAuthor,
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("lightweight-1"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("lightweight-2"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
},
- expectedErr: testhelper.ToInterceptedMetadata(structerr.NewInvalidArgument(
- "%w", storage.NewStorageNotFoundError("fake"),
- )),
},
- }
-
- for _, tc := range testCases {
- t.Run(tc.desc, func(t *testing.T) {
- c, err := client.FindAllTags(ctx, tc.request)
- require.NoError(t, err)
-
- var recvError error
- for recvError == nil {
- _, recvError = c.Recv()
- }
-
- testhelper.RequireGrpcError(t, tc.expectedErr, recvError)
- })
- }
-}
-
-func TestFindAllTags_pagination(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
- cfg, repoProto, repoPath, client := setupRefService(t, ctx)
-
- catfileCache := catfile.NewCache(cfg)
- defer catfileCache.Stop()
-
- annotatedTagID := gittest.WriteTag(t, cfg, repoPath, "annotated", "HEAD", gittest.WriteTagConfig{
- Message: "message",
- })
-
- for _, tc := range []struct {
- desc string
- paginationParams *gitalypb.PaginationParameter
- sortBy *gitalypb.FindAllTagsRequest_SortBy
- expected func(context.Context) ([]string, error)
- }{
{
- desc: "without pagination",
- paginationParams: &gitalypb.PaginationParameter{Limit: 100},
- expected: func(context.Context) ([]string, error) {
- return []string{
- annotatedTagID.String(),
- "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "8f03acbcd11c53d9c9468078f32a2622005a4841",
- }, nil
+ desc: "pagination with limit exceeding tag count",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v2", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v3", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ Limit: 100,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("v1"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("v2"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("v3"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
},
},
{
- desc: "with limit restrictions",
- paginationParams: &gitalypb.PaginationParameter{Limit: 3},
- expected: func(context.Context) ([]string, error) {
- return []string{
- annotatedTagID.String(),
- "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- }, nil
+ desc: "pagination with limit smaller than tag count",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v2", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v3", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ Limit: 2,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("v1"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("v2"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
},
},
{
- desc: "with limit restrictions and page token",
- paginationParams: &gitalypb.PaginationParameter{Limit: 3, PageToken: "refs/tags/v1.0.0"},
- expected: func(context.Context) ([]string, error) {
- return []string{
- "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "8f03acbcd11c53d9c9468078f32a2622005a4841",
- }, nil
+ desc: "pagination with page token and no limit",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, _ := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ PageToken: "refs/tags/v1",
+ },
+ },
+ // It is certainly unexpected that this case should cause an error. I'm not here
+ // to judge though, so I'll let a future developer decide whether this behaviour
+ // is desired or not.
+ expectedErr: structerr.NewInvalidArgument("could not find page token"),
+ }
},
},
{
- desc: "with reversed sort by name, limit restrictions and page token",
- paginationParams: &gitalypb.PaginationParameter{Limit: 3, PageToken: "refs/tags/v1.0.0"},
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME, Direction: gitalypb.SortDirection_DESCENDING},
- expected: func(context.Context) ([]string, error) {
- return []string{
- annotatedTagID.String(),
- }, nil
+ desc: "pagination with page token and limit",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v2", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v3", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v4", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v5", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ Limit: 2,
+ PageToken: "refs/tags/v2",
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("v3"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("v4"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
},
},
{
- desc: "with page token only",
- paginationParams: &gitalypb.PaginationParameter{PageToken: "refs/tags/v1.1.0"},
- expected: func(context.Context) ([]string, error) {
- return nil, structerr.NewInvalidArgument("could not find page token")
+ desc: "pagination with page token and reversed sorting",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, commit := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v2", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v3", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v4", commitID.Revision())
+ gittest.WriteTag(t, cfg, repoPath, "v5", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ Limit: 2,
+ PageToken: "refs/tags/v4",
+ },
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME,
+ Direction: gitalypb.SortDirection_DESCENDING,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ {
+ Name: []byte("v3"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ {
+ Name: []byte("v2"),
+ Id: commitID.String(),
+ TargetCommit: commit,
+ },
+ },
+ }
},
},
{
- desc: "with invalid page token",
- paginationParams: &gitalypb.PaginationParameter{Limit: 3, PageToken: "refs/tags/invalid"},
- expected: func(ctx context.Context) ([]string, error) {
- return nil, structerr.NewInvalidArgument("could not find page token")
+ desc: "pagination with invalid page token",
+ setup: func(t *testing.T) setupData {
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+
+ commitID, _ := writeCommit(t, ctx, cfg, repo)
+ gittest.WriteTag(t, cfg, repoPath, "v1", commitID.Revision())
+
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: repo,
+ PaginationParams: &gitalypb.PaginationParameter{
+ PageToken: "refs/tags/v2",
+ },
+ },
+ expectedErr: structerr.NewInvalidArgument("could not find page token"),
+ }
},
},
- } {
- tc := tc
-
- t.Run(tc.desc, func(t *testing.T) {
- t.Parallel()
-
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{
- Repository: repoProto,
- PaginationParams: tc.paginationParams,
- SortBy: tc.sortBy,
- })
- require.NoError(t, err)
-
- expectedTags, expectedErr := tc.expected(ctx)
-
- var tags []string
- for {
- response, err := c.Recv()
- if err != nil {
- if expectedErr != nil {
- testhelper.RequireGrpcError(t, expectedErr, err)
- break
- } else {
- require.Equal(t, io.EOF, err)
- break
- }
- }
-
- for _, tag := range response.GetTags() {
- tags = append(tags, tag.Id)
- }
- }
-
- require.Equal(t, expectedTags, tags)
- })
- }
-}
-
-func TestFindAllTags_sorted(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
- cfg, repoProto, _, client := setupRefService(t, ctx)
-
- repo := localrepo.NewTestRepo(t, cfg, repoProto)
- headCommit, err := repo.ReadCommit(ctx, "HEAD")
- require.NoError(t, err)
- annotatedTagID, err := repo.WriteTag(ctx, git.ObjectID(headCommit.Id), "commit", []byte("annotated"), []byte("message"), gittest.TestUser, time.Now())
- require.NoError(t, err)
- require.NoError(t, repo.UpdateRef(ctx, "refs/tags/annotated", annotatedTagID, git.ObjectHashSHA1.ZeroOID))
-
- require.NoError(t, repo.ExecAndWait(ctx, git.Command{
- Name: "tag",
- Args: []string{"v1.2.0", headCommit.Id},
- }, git.WithDisabledHooks()))
-
- require.NoError(t, repo.ExecAndWait(ctx, git.Command{
- Name: "tag",
- Args: []string{"v1.10.0", headCommit.Id},
- }, git.WithDisabledHooks()))
-
- for _, tc := range []struct {
- desc string
- sortBy *gitalypb.FindAllTagsRequest_SortBy
- exp map[string]string
- }{
{
- desc: "by name",
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME},
- exp: map[string]string{
- "annotated": annotatedTagID.String(),
- "v1.0.0": "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "v1.1.0": "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "v1.1.1": "8f03acbcd11c53d9c9468078f32a2622005a4841",
- "v1.10.0": headCommit.Id,
- "v1.2.0": headCommit.Id,
+ desc: "sort by refname",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: sortSetup.repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ sortSetup.tag1_0.tag, sortSetup.tag1_10.tag, sortSetup.tag1_2.tag,
+ },
+ }
},
},
{
- desc: "by semantic name in ascending order",
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_VERSION_REFNAME, Direction: gitalypb.SortDirection_ASCENDING},
- exp: map[string]string{
- "annotated": annotatedTagID.String(),
- "v1.0.0": "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "v1.1.0": "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "v1.1.1": "8f03acbcd11c53d9c9468078f32a2622005a4841",
- "v1.2.0": headCommit.Id,
- "v1.10.0": headCommit.Id,
+ desc: "sort by ascending semantic version",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: sortSetup.repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_VERSION_REFNAME,
+ Direction: gitalypb.SortDirection_ASCENDING,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ sortSetup.tag1_0.tag, sortSetup.tag1_2.tag, sortSetup.tag1_10.tag,
+ },
+ }
},
},
{
- desc: "by semantic name in descending order",
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_VERSION_REFNAME, Direction: gitalypb.SortDirection_DESCENDING},
- exp: map[string]string{
- "v1.10.0": headCommit.Id,
- "v1.2.0": headCommit.Id,
- "v1.1.1": "8f03acbcd11c53d9c9468078f32a2622005a4841",
- "v1.1.0": "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "v1.0.0": "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "annotated": annotatedTagID.String(),
+ desc: "sort by descending semantic version",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: sortSetup.repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_VERSION_REFNAME,
+ Direction: gitalypb.SortDirection_DESCENDING,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ sortSetup.tag1_10.tag, sortSetup.tag1_2.tag, sortSetup.tag1_0.tag,
+ },
+ }
},
},
{
- desc: "by updated in ascending order",
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_CREATORDATE, Direction: gitalypb.SortDirection_ASCENDING},
- exp: map[string]string{
- "v1.0.0": "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
- "v1.1.0": "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "v1.10.0": headCommit.Id,
- "v1.2.0": headCommit.Id,
- "v1.1.1": "8f03acbcd11c53d9c9468078f32a2622005a4841",
- "annotated": annotatedTagID.String(),
+ desc: "sort by ascending creator date",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: sortSetup.repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_CREATORDATE,
+ Direction: gitalypb.SortDirection_ASCENDING,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ sortSetup.tag1_2.tag, sortSetup.tag1_0.tag, sortSetup.tag1_10.tag,
+ },
+ }
},
},
{
- desc: "by updated in descending order",
- sortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_CREATORDATE, Direction: gitalypb.SortDirection_DESCENDING},
- exp: map[string]string{
- "annotated": annotatedTagID.String(),
- "v1.1.0": "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
- "v1.10.0": headCommit.Id,
- "v1.2.0": headCommit.Id,
- "v1.1.1": "8f03acbcd11c53d9c9468078f32a2622005a4841",
- "v1.0.0": "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8",
+ desc: "sort by descending creator date",
+ setup: func(t *testing.T) setupData {
+ return setupData{
+ request: &gitalypb.FindAllTagsRequest{
+ Repository: sortSetup.repo,
+ SortBy: &gitalypb.FindAllTagsRequest_SortBy{
+ Key: gitalypb.FindAllTagsRequest_SortBy_CREATORDATE,
+ Direction: gitalypb.SortDirection_DESCENDING,
+ },
+ },
+ expectedTags: []*gitalypb.Tag{
+ sortSetup.tag1_10.tag, sortSetup.tag1_0.tag, sortSetup.tag1_2.tag,
+ },
+ }
},
},
} {
@@ -687,75 +703,28 @@ func TestFindAllTags_sorted(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{
- Repository: repoProto,
- SortBy: tc.sortBy,
- })
- require.NoError(t, err)
+ setup := tc.setup(t)
- tags := make(map[string]string)
- for {
- r, err := c.Recv()
- if err == io.EOF {
- break
- }
- require.NoError(t, err)
- for _, tag := range r.GetTags() {
- tags[string(tag.Name)] = tag.Id
- }
- }
+ stream, err := client.FindAllTags(ctx, setup.request)
+ require.NoError(t, err)
- require.Equal(t, tc.exp, tags)
+ tags, err := testhelper.ReceiveAndFold(stream.Recv, func(
+ result []*gitalypb.Tag,
+ response *gitalypb.FindAllTagsResponse,
+ ) []*gitalypb.Tag {
+ return append(result, response.GetTags()...)
+ })
+ testhelper.RequireGrpcError(t, setup.expectedErr, err)
+ testhelper.ProtoEqual(t, setup.expectedTags, tags)
})
}
-
- t.Run("by unsupported key", func(t *testing.T) {
- t.Parallel()
-
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{
- Repository: repoProto,
- SortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_Key(-1)},
- })
- require.NoError(t, err)
- r, err := c.Recv()
- testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, "unsupported sorting key: -1"), err)
- require.Nil(t, r)
- })
-
- t.Run("by unsupported direction", func(t *testing.T) {
- t.Parallel()
-
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{
- Repository: repoProto,
- SortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME, Direction: gitalypb.SortDirection(-1)},
- })
- require.NoError(t, err)
- r, err := c.Recv()
- testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, "unsupported sorting direction: -1"), err)
- require.Nil(t, r)
- })
-
- t.Run("no tags", func(t *testing.T) {
- t.Parallel()
-
- repoProto, _ := gittest.CreateRepository(t, ctx, cfg)
- c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{
- Repository: repoProto,
- SortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME},
- })
- require.NoError(t, err)
-
- r, err := c.Recv()
- require.Equal(t, io.EOF, err)
- require.Nil(t, r)
- })
}
func BenchmarkFindAllTags(b *testing.B) {
b.StopTimer()
ctx := testhelper.Context(b)
- cfg, client := setupRefServiceWithoutRepo(b)
+ cfg, client := setupRefService(b)
repoProto, repoPath := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
@@ -786,3 +755,53 @@ func BenchmarkFindAllTags(b *testing.B) {
}
})
}
+
+type sortSetupTag struct {
+ commit *gitalypb.GitCommit
+ tag *gitalypb.Tag
+ tagID git.ObjectID
+}
+
+type sortSetup struct {
+ repo *gitalypb.Repository
+ repoPath string
+ tag1_0, tag1_2, tag1_10 sortSetupTag
+}
+
+func setupSortRepository(tb testing.TB, ctx context.Context, cfg config.Cfg) sortSetup {
+ repo, repoPath := gittest.CreateRepository(tb, ctx, cfg)
+
+ return sortSetup{
+ repo: repo,
+ repoPath: repoPath,
+ tag1_0: setupTaggedCommit(tb, ctx, cfg, repo, repoPath, "v1.0", time.Date(2010, 1, 1, 0, 0, 0, 0, time.UTC)),
+ tag1_2: setupTaggedCommit(tb, ctx, cfg, repo, repoPath, "v1.2", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)),
+ tag1_10: setupTaggedCommit(tb, ctx, cfg, repo, repoPath, "v1.10", time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)),
+ }
+}
+
+func setupTaggedCommit(tb testing.TB, ctx context.Context, cfg config.Cfg, repo *gitalypb.Repository, repoPath string, tagName string, tagDate time.Time) sortSetupTag {
+ commitID, commit := writeCommit(tb, ctx, cfg, repo)
+ tagID := gittest.WriteTag(tb, cfg, repoPath, tagName, commitID.Revision(), gittest.WriteTagConfig{
+ Message: tagName,
+ Date: tagDate,
+ })
+
+ return sortSetupTag{
+ commit: commit,
+ tagID: tagID,
+ tag: &gitalypb.Tag{
+ Name: []byte(tagName),
+ Id: tagID.String(),
+ Message: []byte(tagName),
+ MessageSize: int64(len(tagName)),
+ Tagger: &gitalypb.CommitAuthor{
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(tagDate),
+ Timezone: []byte(tagDate.Format("-0700")),
+ },
+ TargetCommit: commit,
+ },
+ }
+}
diff --git a/internal/gitaly/service/ref/find_default_branch_name_test.go b/internal/gitaly/service/ref/find_default_branch_name_test.go
index 14e004e88..7570c44de 100644
--- a/internal/gitaly/service/ref/find_default_branch_name_test.go
+++ b/internal/gitaly/service/ref/find_default_branch_name_test.go
@@ -22,7 +22,7 @@ func TestFindDefaultBranchName(t *testing.T) {
}
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
for _, tc := range []struct {
desc string
diff --git a/internal/gitaly/service/ref/find_local_branches_test.go b/internal/gitaly/service/ref/find_local_branches_test.go
index 85667317e..3e3064901 100644
--- a/internal/gitaly/service/ref/find_local_branches_test.go
+++ b/internal/gitaly/service/ref/find_local_branches_test.go
@@ -19,7 +19,7 @@ func TestFindLocalBranches(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
type setupData struct {
request *gitalypb.FindLocalBranchesRequest
diff --git a/internal/gitaly/service/ref/find_refs_by_oid_test.go b/internal/gitaly/service/ref/find_refs_by_oid_test.go
index cbeb5275d..b7ac3d779 100644
--- a/internal/gitaly/service/ref/find_refs_by_oid_test.go
+++ b/internal/gitaly/service/ref/find_refs_by_oid_test.go
@@ -21,7 +21,7 @@ func TestFindRefsByOID_successful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
oid := gittest.WriteCommit(t, cfg, repoPath)
@@ -123,7 +123,7 @@ func TestFindRefsByOID_failure(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
equalError := func(t *testing.T, expected error) func(error) {
return func(actual error) {
@@ -237,7 +237,7 @@ func TestFindRefsByOID_validation(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, _ := gittest.CreateRepository(t, ctx, cfg)
testCases := map[string]struct {
diff --git a/internal/gitaly/service/ref/find_tag_test.go b/internal/gitaly/service/ref/find_tag_test.go
index 3f8126248..7439358f2 100644
--- a/internal/gitaly/service/ref/find_tag_test.go
+++ b/internal/gitaly/service/ref/find_tag_test.go
@@ -21,7 +21,7 @@ func TestFindTag(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
type setupData struct {
request *gitalypb.FindTagRequest
diff --git a/internal/gitaly/service/ref/list_refs_test.go b/internal/gitaly/service/ref/list_refs_test.go
index 150709392..b831f22e1 100644
--- a/internal/gitaly/service/ref/list_refs_test.go
+++ b/internal/gitaly/service/ref/list_refs_test.go
@@ -20,7 +20,7 @@ func TestServer_ListRefs(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
@@ -257,7 +257,7 @@ func TestListRefs_validate(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, _ := gittest.CreateRepository(t, ctx, cfg)
for _, tc := range []struct {
diff --git a/internal/gitaly/service/ref/refexists_test.go b/internal/gitaly/service/ref/refexists_test.go
index e32e11aac..ec798ac87 100644
--- a/internal/gitaly/service/ref/refexists_test.go
+++ b/internal/gitaly/service/ref/refexists_test.go
@@ -15,7 +15,7 @@ func TestRefExists(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
commitID := gittest.WriteCommit(t, cfg, repoPath)
diff --git a/internal/gitaly/service/ref/refnames_containing_test.go b/internal/gitaly/service/ref/refnames_containing_test.go
index b4e4cc053..3e282b587 100644
--- a/internal/gitaly/service/ref/refnames_containing_test.go
+++ b/internal/gitaly/service/ref/refnames_containing_test.go
@@ -17,7 +17,7 @@ func TestListTagNamesContainingCommit(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
@@ -121,7 +121,7 @@ func TestListBranchNamesContainingCommit(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
rootCommitID := gittest.WriteCommit(t, cfg, repoPath)
diff --git a/internal/gitaly/service/ref/remote_branches_test.go b/internal/gitaly/service/ref/remote_branches_test.go
deleted file mode 100644
index e7453f15f..000000000
--- a/internal/gitaly/service/ref/remote_branches_test.go
+++ /dev/null
@@ -1,142 +0,0 @@
-//go:build !gitaly_test_sha256
-
-package ref
-
-import (
- "fmt"
- "io"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
- "gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
- "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
- "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-)
-
-func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
-
- cfg, repoProto, repoPath, client := setupRefService(t, ctx)
-
- repo := localrepo.NewTestRepo(t, cfg, repoProto)
-
- remoteName := "my-remote"
- expectedBranches := map[string]git.ObjectID{
- "foo": "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd",
- "bar": "60ecb67744cb56576c30214ff52294f8ce2def98",
- }
- excludedRemote := "my-remote-2"
- excludedBranches := map[string]git.ObjectID{
- "from-another-remote": "5937ac0a7beb003549fc5fd26fc247adbce4a52e",
- }
-
- for branchName, commitID := range expectedBranches {
- gittest.WriteRef(t, cfg, repoPath, git.ReferenceName(fmt.Sprintf("refs/remotes/%s/%s", remoteName, branchName)), commitID)
- }
-
- for branchName, commitID := range excludedBranches {
- gittest.WriteRef(t, cfg, repoPath, git.ReferenceName(fmt.Sprintf("refs/remotes/%s/%s", excludedRemote, branchName)), commitID)
- }
-
- request := &gitalypb.FindAllRemoteBranchesRequest{Repository: repoProto, RemoteName: remoteName}
-
- c, err := client.FindAllRemoteBranches(ctx, request)
- require.NoError(t, err)
-
- branches := readFindAllRemoteBranchesResponsesFromClient(t, c)
- require.Len(t, branches, len(expectedBranches))
-
- for branchName, commitID := range expectedBranches {
- targetCommit, err := repo.ReadCommit(ctx, git.Revision(commitID))
- require.NoError(t, err)
-
- expectedBranch := &gitalypb.Branch{
- Name: []byte("refs/remotes/" + remoteName + "/" + branchName),
- TargetCommit: targetCommit,
- }
-
- require.Contains(t, branches, expectedBranch)
- }
-
- for branchName, commitID := range excludedBranches {
- targetCommit, err := repo.ReadCommit(ctx, git.Revision(commitID))
- require.NoError(t, err)
-
- excludedBranch := &gitalypb.Branch{
- Name: []byte("refs/remotes/" + excludedRemote + "/" + branchName),
- TargetCommit: targetCommit,
- }
-
- require.NotContains(t, branches, excludedBranch)
- }
-}
-
-func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
- _, repo, _, client := setupRefService(t, ctx)
-
- testCases := []struct {
- description string
- request *gitalypb.FindAllRemoteBranchesRequest
- expectedErr error
- }{
- {
- description: "Invalid repo",
- request: &gitalypb.FindAllRemoteBranchesRequest{
- Repository: &gitalypb.Repository{
- StorageName: "fake",
- RelativePath: "repo",
- },
- RemoteName: "stub",
- },
- expectedErr: testhelper.ToInterceptedMetadata(structerr.NewInvalidArgument(
- "%w", storage.NewStorageNotFoundError("fake"),
- )),
- },
- {
- description: "Empty repo",
- request: &gitalypb.FindAllRemoteBranchesRequest{RemoteName: "myRemote"},
- expectedErr: structerr.NewInvalidArgument("%w", storage.ErrRepositoryNotSet),
- },
- {
- description: "Empty remote name",
- request: &gitalypb.FindAllRemoteBranchesRequest{Repository: repo},
- expectedErr: status.Error(codes.InvalidArgument, "empty RemoteName"),
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.description, func(t *testing.T) {
- c, err := client.FindAllRemoteBranches(ctx, tc.request)
- require.NoError(t, err)
- _, recvError := c.Recv()
- testhelper.RequireGrpcError(t, tc.expectedErr, recvError)
- })
- }
-}
-
-func readFindAllRemoteBranchesResponsesFromClient(t *testing.T, c gitalypb.RefService_FindAllRemoteBranchesClient) []*gitalypb.Branch {
- var branches []*gitalypb.Branch
-
- for {
- r, err := c.Recv()
- if err == io.EOF {
- break
- }
- require.NoError(t, err)
-
- branches = append(branches, r.GetBranches()...)
- }
-
- return branches
-}
diff --git a/internal/gitaly/service/ref/tag_messages_test.go b/internal/gitaly/service/ref/tag_messages_test.go
index f1c6ef130..b090e8d13 100644
--- a/internal/gitaly/service/ref/tag_messages_test.go
+++ b/internal/gitaly/service/ref/tag_messages_test.go
@@ -18,7 +18,7 @@ func TestSuccessfulGetTagMessagesRequest(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
@@ -58,7 +58,7 @@ func TestSuccessfulGetTagMessagesRequest(t *testing.T) {
func TestFailedGetTagMessagesRequest(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, client := setupRefServiceWithoutRepo(t)
+ _, client := setupRefService(t)
testCases := []struct {
desc string
diff --git a/internal/gitaly/service/ref/tag_signatures_test.go b/internal/gitaly/service/ref/tag_signatures_test.go
index 6605165dc..144fb8cde 100644
--- a/internal/gitaly/service/ref/tag_signatures_test.go
+++ b/internal/gitaly/service/ref/tag_signatures_test.go
@@ -1,5 +1,3 @@
-//go:build !gitaly_test_sha256
-
package ref
import (
@@ -8,6 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
@@ -22,22 +21,32 @@ func TestGetTagSignatures(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
+ cfg, client := setupRefService(t)
+
+ repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg)
- cfg, repoProto, repoPath, client := setupRefService(t, ctx)
+ plainCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("plain signed commit"), gittest.WithBranch(git.DefaultBranch))
+ plainSignature := `-----BEGIN SIGNED MESSAGE-----
+MIISfwYJKoZIhvcNAQcCoIIScDCCEmwCAQExDTALBglghkgBZQMEAgEwCwYJKoZI
+-----END SIGNED MESSAGE-----`
+ plainMessage := strings.Repeat("a", helper.MaxCommitOrTagMessageSize) + "\n"
+ plainTagID := gittest.WriteTag(t, cfg, repoPath, "plain-signed-tag", plainCommitID.Revision(), gittest.WriteTagConfig{Message: plainMessage + plainSignature})
+ plainContent := fmt.Sprintf("object %s\ntype commit\ntag plain-signed-tag\ntagger %s\n\n%s", plainCommitID, gittest.DefaultCommitterSignature, plainMessage)
- 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 := fmt.Sprintf("object 1e292f8fedd741b75372e19097c76d327140c312\ntype commit\ntag big-tag-1\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message1)
+ pgpCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("PGP signed commit"))
+ pgpSignature := `-----BEGIN PGP SIGNATURE-----
+iJwEAAEIAAYFAlmmbf0ACgkQv52SX5Ee/WVv1gP/WrjclOc3CYiTrTgNuxs/vyXl
+-----END PGP SIGNATURE-----`
+ pgpMessage := strings.Repeat("b", helper.MaxCommitOrTagMessageSize) + "\n"
+ pgpTagID := gittest.WriteTag(t, cfg, repoPath, "pgp-signed-tag", pgpCommitID.Revision(), gittest.WriteTagConfig{Message: pgpMessage + pgpSignature})
+ pgpContent := fmt.Sprintf("object %s\ntype commit\ntag pgp-signed-tag\ntagger %s\n\n%s", pgpCommitID, gittest.DefaultCommitterSignature, pgpMessage)
- 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 := fmt.Sprintf("object 7975be0116940bf2ad4321f79d02a55c5f7779aa\ntype commit\ntag big-tag-2\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message2)
+ unsignedCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("unsigned commit"))
+ unsignedMessage := "tag message\n"
+ unsignedTagID := gittest.WriteTag(t, cfg, repoPath, "unsigned-tag", unsignedCommitID.Revision(), gittest.WriteTagConfig{Message: unsignedMessage})
+ unsignedContent := fmt.Sprintf("object %s\ntype commit\ntag unsigned-tag\ntagger %s\n\n%s", unsignedCommitID, gittest.DefaultCommitterSignature, unsignedMessage)
- message3 := "tag message\n"
- tag3ID := gittest.WriteTag(t, cfg, repoPath, "tag-3", "master~~", gittest.WriteTagConfig{Message: message3})
- content3 := fmt.Sprintf("object 60ecb67744cb56576c30214ff52294f8ce2def98\ntype commit\ntag tag-3\ntagger %s\n\n%s", gittest.DefaultCommitterSignature, message3)
+ invalidObjectID := gittest.DefaultObjectHash.HashData([]byte("invalid object"))
for _, tc := range []struct {
desc string
@@ -63,92 +72,92 @@ func TestGetTagSignatures(t *testing.T) {
{
desc: "unknown id",
revisions: []string{
- "b10ff336f3fbfb131431c4959915cdfd1b49c635",
+ invalidObjectID.String(),
},
- expectedErr: status.Error(codes.Internal, "cat-file iterator stop: rev-list pipeline command: exit status 128, stderr: \"fatal: bad object b10ff336f3fbfb131431c4959915cdfd1b49c635\\n\""),
+ expectedErr: structerr.NewInternal("cat-file iterator stop: rev-list pipeline command: exit status 128, stderr: \"fatal: bad object %s\\n\"", invalidObjectID),
},
{
desc: "commit id",
revisions: []string{
- "1e292f8fedd741b75372e19097c76d327140c312",
+ plainCommitID.String(),
},
expectedSignatures: nil,
},
{
desc: "commit ref",
revisions: []string{
- "refs/heads/master",
+ git.DefaultBranch,
},
expectedSignatures: nil,
},
{
desc: "single tag signature",
revisions: []string{
- tag1ID.String(),
+ plainTagID.String(),
},
expectedSignatures: []*gitalypb.GetTagSignaturesResponse_TagSignature{
{
- TagId: tag1ID.String(),
- Signature: []byte(signature1),
- Content: []byte(content1),
+ TagId: plainTagID.String(),
+ Signature: []byte(plainSignature),
+ Content: []byte(plainContent),
},
},
},
{
desc: "single tag signature by short SHA",
revisions: []string{
- tag1ID.String()[:7],
+ plainTagID.String()[:7],
},
expectedSignatures: []*gitalypb.GetTagSignaturesResponse_TagSignature{
{
- TagId: tag1ID.String(),
- Signature: []byte(signature1),
- Content: []byte(content1),
+ TagId: plainTagID.String(),
+ Signature: []byte(plainSignature),
+ Content: []byte(plainContent),
},
},
},
{
desc: "single tag signature by ref",
revisions: []string{
- "refs/tags/big-tag-1",
+ "refs/tags/plain-signed-tag",
},
expectedSignatures: []*gitalypb.GetTagSignaturesResponse_TagSignature{
{
- TagId: tag1ID.String(),
- Signature: []byte(signature1),
- Content: []byte(content1),
+ TagId: plainTagID.String(),
+ Signature: []byte(plainSignature),
+ Content: []byte(plainContent),
},
},
},
{
desc: "multiple tag signatures",
revisions: []string{
- tag1ID.String(),
- tag2ID.String(),
+ plainTagID.String(),
+ pgpTagID.String(),
},
expectedSignatures: []*gitalypb.GetTagSignaturesResponse_TagSignature{
{
- TagId: tag1ID.String(),
- Signature: []byte(signature1),
- Content: []byte(content1),
+ TagId: plainTagID.String(),
+ Signature: []byte(plainSignature),
+ Content: []byte(plainContent),
},
{
- TagId: tag2ID.String(),
- Signature: []byte(signature2),
- Content: []byte(content2),
+ TagId: pgpTagID.String(),
+ Signature: []byte(pgpSignature),
+ Content: []byte(pgpContent),
},
},
},
{
desc: "tag without signature",
revisions: []string{
- tag3ID.String(),
+ unsignedTagID.String(),
},
expectedSignatures: []*gitalypb.GetTagSignaturesResponse_TagSignature{
{
- TagId: tag3ID.String(),
+ TagId: unsignedTagID.String(),
Signature: []byte(""),
- Content: []byte(content3),
+ Content: []byte(unsignedContent),
},
},
},
@@ -186,8 +195,10 @@ func TestGetTagSignatures(t *testing.T) {
func TestGetTagSignatures_validate(t *testing.T) {
t.Parallel()
+
ctx := testhelper.Context(t)
- _, repoProto, _, client := setupRefService(t, ctx)
+ cfg, client := setupRefService(t)
+ repoProto, _ := gittest.CreateRepository(t, ctx, cfg)
for _, tc := range []struct {
desc string
diff --git a/internal/gitaly/service/ref/testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature b/internal/gitaly/service/ref/testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature
deleted file mode 100644
index 185345505..000000000
--- a/internal/gitaly/service/ref/testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature
+++ /dev/null
@@ -1,6 +0,0 @@
------BEGIN PGP SIGNATURE-----
-iJwEAAEIAAYFAlmmbf0ACgkQv52SX5Ee/WVv1gP/WrjclOc3CYiTrTgNuxs/vyXl
-PtUrxbOYEpQtRV+id/agJgaJWKoHRYUoXSGBuykijsND43PMkrjfZiF2SbE0j0CS
-7oukSx83us+y/hn+ecZQG0OkrBZ2vQ9gHGbEN9RFyZXfgWtRcgqFnFZUxCznhzzk
-njAjb08aUpn9r8WHsdU=\n=HLte
------END PGP SIGNATURE----- \ No newline at end of file
diff --git a/internal/gitaly/service/ref/testdata/tag-7975be0116940bf2ad4321f79d02a55c5f7779aa-signature b/internal/gitaly/service/ref/testdata/tag-7975be0116940bf2ad4321f79d02a55c5f7779aa-signature
deleted file mode 100644
index bbdfc7bf6..000000000
--- a/internal/gitaly/service/ref/testdata/tag-7975be0116940bf2ad4321f79d02a55c5f7779aa-signature
+++ /dev/null
@@ -1,101 +0,0 @@
------BEGIN SIGNED MESSAGE-----
-MIISfwYJKoZIhvcNAQcCoIIScDCCEmwCAQExDTALBglghkgBZQMEAgEwCwYJKoZI
-hvcNAQcBoIIP8zCCB3QwggVcoAMCAQICBBXXLOIwDQYJKoZIhvcNAQELBQAwgbYx
-CzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCYXllcm4xETAPBgNVBAcMCE11ZW5jaGVu
-MRAwDgYDVQQKDAdTaWVtZW5zMREwDwYDVQQFEwhaWlpaWlpBNjEdMBsGA1UECwwU
-U2llbWVucyBUcnVzdCBDZW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QghL5VdzqfA8FCL/j4XC9yI6
-csZTAQi73xFQYVjZt3+aoSz84lOlTmVo/jgvGMY/JzH9I4mETGgAJRNj34Z/0meh
-M+pKWCojNH/dgyJSwDGCAlIwggJOAgEBMIG/MIG2MQswCQYDVQQGEwJERTEPMA0G
-A1UECAwGQmF5ZXJuMREwDwYDVQQHDAhNdWVuY2hlbjEQMA4GA1UECgwHU2llbWVu
-czERMA8GA1UEBRMIWlpaWlpaQTYxHTAbBgNVBAsMFFNpZW1lbnMgVHJ1c3QgQ2Vu
-dGVyMT8wPQYDVQQDDDZTaWVtZW5zIElzc3VpbmcgQ0EgTWVkaXVtIFN0cmVuZ3Ro
-IEF1dGhlbnRpY2F0aW9uIDIwMTYCBBXXLOIwCwYJYIZIAWUDBAIBoGkwHAYJKoZI
-hvcNAQkFMQ8XDTE5MTEyMDE0NTYyMFowLwYJKoZIhvcNAQkEMSIEIJDnZUpcVLzC
-OdtpkH8gtxwLPIDE0NmAmFC9uM8q2z+OMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0B
-BwEwCwYJKoZIhvcNAQEBBIIBAH/Pqv2xp3a0jSPkwU1K3eGA/1lfoNJMUny4d/PS
-LVWlkgrmedXdLmuBzAGEaaZOJS0lEpNd01pR/reHs7xxZ+RZ0olTs2ufM0CijQSx
-OL9HDl2O3OoD77NWx4tl3Wy1yJCeV3XH/cEI7AkKHCmKY9QMoMYWh16ORBtr+YcS
-YK+gONOjpjgcgTJgZ3HSFgQ50xiD4WT1kFBHsuYsLqaOSbTfTN6Ayyg4edjrPQqa
-VcVf1OQcIrfWA3yMQrnEZfOYfN/D4EPjTfxBV+VCi/F2bdZmMbJ7jNk1FbewSwWO
-SDH1i0K32NyFbnh0BSos7njq7ELqKlYBsoB/sZfaH2vKy5U=
------END SIGNED MESSAGE----- \ No newline at end of file
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index a76cf03df..d2f077855 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -30,15 +30,7 @@ func TestMain(m *testing.M) {
}))
}
-func setupRefService(tb testing.TB, ctx context.Context) (config.Cfg, *gitalypb.Repository, string, gitalypb.RefServiceClient) {
- cfg, client := setupRefServiceWithoutRepo(tb)
- repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
- return cfg, repo, repoPath, client
-}
-
-func setupRefServiceWithoutRepo(tb testing.TB) (config.Cfg, gitalypb.RefServiceClient) {
+func setupRefService(tb testing.TB) (config.Cfg, gitalypb.RefServiceClient) {
cfg := testcfg.Build(tb)
testcfg.BuildGitalyHooks(tb, cfg)
diff --git a/internal/gitaly/service/ref/update_references_test.go b/internal/gitaly/service/ref/update_references_test.go
index 68c1f121f..19b287a2a 100644
--- a/internal/gitaly/service/ref/update_references_test.go
+++ b/internal/gitaly/service/ref/update_references_test.go
@@ -20,7 +20,7 @@ func TestUpdateReferences(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, client := setupRefServiceWithoutRepo(t)
+ cfg, client := setupRefService(t)
missingCommitID := bytes.Repeat([]byte("1"), gittest.DefaultObjectHash.EncodedLen())