diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2018-03-16 23:47:06 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2018-03-29 15:43:48 +0300 |
commit | 80cbe03c615c019afd7ea366d638adc2eadc9538 (patch) | |
tree | 65a7928b43e1ac1bc54aa94b2a3fd645b0b0cb44 /internal/git | |
parent | 389fdd0aeb56564b5f20b64690f608b431481bed (diff) |
Add handling for large commit and tag messages
Diffstat (limited to 'internal/git')
-rw-r--r-- | internal/git/helper.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/git/helper.go b/internal/git/helper.go index 1904e9f86..5e816584f 100644 --- a/internal/git/helper.go +++ b/internal/git/helper.go @@ -11,6 +11,7 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/internal/command" + "gitlab.com/gitlab-org/gitaly/internal/helper" ) // FallbackTimeValue is the value returned by `SafeTimeParse` in case it @@ -64,14 +65,23 @@ func NewCommit(id, subject, body, authorName, authorEmail, authorDate, Date: ×tamp.Timestamp{Seconds: committerDateTime.Unix()}, } - return &pb.GitCommit{ + commit := &pb.GitCommit{ Id: string(id), Subject: subject, - Body: body, Author: &author, Committer: &committer, ParentIds: parentIds, - }, nil + BodySize: int64(len(body)), + } + + bodyLengthToSend := len(body) + if threshold := helper.MaxCommitOrTagMessageSize; bodyLengthToSend > threshold { + bodyLengthToSend = threshold + } + + commit.Body = body[:bodyLengthToSend] + + return commit, nil } // Version returns the used git version. |