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:
Diffstat (limited to 'internal/git/catfile/object_content_reader_test.go')
-rw-r--r--internal/git/catfile/object_content_reader_test.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/internal/git/catfile/object_content_reader_test.go b/internal/git/catfile/object_content_reader_test.go
index 915dc6465..502a68ec6 100644
--- a/internal/git/catfile/object_content_reader_test.go
+++ b/internal/git/catfile/object_content_reader_test.go
@@ -1,6 +1,7 @@
package catfile
import (
+ "context"
"errors"
"fmt"
"io"
@@ -10,6 +11,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
@@ -19,8 +21,12 @@ import (
)
func TestObjectContentReader_reader(t *testing.T) {
- ctx := testhelper.Context(t)
+ t.Parallel()
+
+ testhelper.NewFeatureSets(featureflag.MailmapOptions).Run(t, testObjectContentReader)
+}
+func testObjectContentReader(t *testing.T, ctx context.Context) {
cfg := testcfg.Build(t)
repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
@@ -128,6 +134,35 @@ func TestObjectContentReader_reader(t *testing.T) {
require.NoError(t, err)
}
})
+
+ t.Run("read existing object with mailmap", func(t *testing.T) {
+ mailmapContents := "A U Thor <author@example.com> Scrooge McDuck <scrooge@mcduck.com>"
+
+ commitID := gittest.WriteCommit(t, cfg, repoPath,
+ gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: ".mailmap", Mode: "100644", Content: mailmapContents},
+ ),
+ gittest.WithBranch("main"),
+ )
+
+ commitContents := gittest.Exec(t, cfg, "-C", repoPath, "cat-file",
+ "-p", commitID.String())
+
+ if featureflag.MailmapOptions.IsEnabled(ctx) {
+ commitContents = gittest.Exec(t, cfg, "-C", repoPath, "cat-file",
+ "--use-mailmap", "-p", commitID.String())
+ }
+
+ reader, err := newObjectContentReader(ctx, newRepoExecutor(t, cfg, repoProto), nil)
+ require.NoError(t, err)
+
+ object, err := reader.Object(ctx, "refs/heads/main")
+ require.NoError(t, err)
+
+ data, err := io.ReadAll(object)
+ require.NoError(t, err)
+ require.Equal(t, commitContents, data)
+ })
}
func TestObjectContentReader_queue(t *testing.T) {