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-09-27 14:59:11 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-27 14:59:11 +0300
commitb0ff1664aabecd7d11d118e6cb0b02824aae3cb4 (patch)
tree8a7082f2e99df178a976d63041ab4fba71b2f88b
parent26429785e300cc80f0f1d4856e25ab32df1cbf2c (diff)
parent086f03f68cad3560c7fd06a825999b0841dbe898 (diff)
Merge branch 'fix-blameLineCountErrorRegexp' into 'master'
Fix blameLineCountErrorRegexp See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6414 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Adeline Yeung <ayeung@gitlab.com> Co-authored-by: Ahmad Sherif <ahmad@gitlab.com>
-rw-r--r--internal/gitaly/service/commit/raw_blame.go2
-rw-r--r--internal/gitaly/service/commit/raw_blame_test.go11
2 files changed, 7 insertions, 6 deletions
diff --git a/internal/gitaly/service/commit/raw_blame.go b/internal/gitaly/service/commit/raw_blame.go
index 09c1b8cc4..d4254bc50 100644
--- a/internal/gitaly/service/commit/raw_blame.go
+++ b/internal/gitaly/service/commit/raw_blame.go
@@ -16,7 +16,7 @@ import (
var (
validBlameRange = regexp.MustCompile(`\A\d+,\d+\z`)
- blameLineCountErrorRegexp = regexp.MustCompile("^fatal: file .* has only (\\d) lines?\n$")
+ blameLineCountErrorRegexp = regexp.MustCompile("^fatal: file .* has only (\\d+) lines?\n$")
)
func (s *server) RawBlame(in *gitalypb.RawBlameRequest, stream gitalypb.CommitService_RawBlameServer) error {
diff --git a/internal/gitaly/service/commit/raw_blame_test.go b/internal/gitaly/service/commit/raw_blame_test.go
index cb0e5b76b..b3da3d99e 100644
--- a/internal/gitaly/service/commit/raw_blame_test.go
+++ b/internal/gitaly/service/commit/raw_blame_test.go
@@ -3,6 +3,7 @@ package commit
import (
"fmt"
"io"
+ "strings"
"testing"
"github.com/stretchr/testify/require"
@@ -119,9 +120,9 @@ func TestRawBlame(t *testing.T) {
setup: func(t *testing.T) setupData {
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
- // We write a file with three lines, only, but the request asks us to blame line 10.
+ // We write a file with 10 lines, only, but the request asks us to blame line 11.
commit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
- gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\n"},
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: strings.Repeat("a\n", 10)},
))
return setupData{
@@ -129,17 +130,17 @@ func TestRawBlame(t *testing.T) {
Repository: repo,
Revision: []byte(commit),
Path: []byte("path"),
- Range: []byte("10,10"),
+ Range: []byte("11,11"),
},
expectedErr: testhelper.ToInterceptedMetadata(
structerr.NewInvalidArgument("range is outside of the file length").
WithMetadata("revision", commit.String()).
WithMetadata("path", "path").
- WithMetadata("lines", 3).
+ WithMetadata("lines", 10).
WithDetail(&gitalypb.RawBlameError{
Error: &gitalypb.RawBlameError_OutOfRange{
OutOfRange: &gitalypb.RawBlameError_OutOfRangeError{
- ActualLines: 3,
+ ActualLines: 10,
},
},
}),