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-05-03 08:47:46 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-03 09:00:03 +0300
commiteef6255ae713f17cebef4839607862ea143fa225 (patch)
tree853f25dca3c4a0a0fa57babb7dc5698529540730
parentbb1c2baba8ad5a72715d01c7b9820e2a4563469b (diff)
git: Move fallback time into `catfile` package
When we fail to parse the commit time in the `catfile` package, then we instead return a fallback time. While the `catfile` package is the only user of this value, it is currently contained in the `git` package as a public variable. Move it over into the `catfile` package to keep it close to its user.
-rw-r--r--internal/git/catfile/parser.go8
-rw-r--r--internal/git/proto.go6
2 files changed, 7 insertions, 7 deletions
diff --git a/internal/git/catfile/parser.go b/internal/git/catfile/parser.go
index 41e8e5029..d5d5488f5 100644
--- a/internal/git/catfile/parser.go
+++ b/internal/git/catfile/parser.go
@@ -7,6 +7,7 @@ import (
"io"
"strconv"
"strings"
+ "time"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
@@ -124,6 +125,11 @@ func (p *parser) ParseCommit(object git.Object) (*gitalypb.GitCommit, error) {
const maxUnixCommitDate = 1 << 53
+// fallbackTimeValue is the value returned in case there is a parse error. It's the maximum
+// time value possible in golang. See
+// https://gitlab.com/gitlab-org/gitaly/issues/556#note_40289573
+var fallbackTimeValue = time.Unix(1<<63-62135596801, 999999999)
+
func parseCommitAuthor(line string) *gitalypb.CommitAuthor {
author := &gitalypb.CommitAuthor{}
@@ -149,7 +155,7 @@ func parseCommitAuthor(line string) *gitalypb.CommitAuthor {
sec, err := strconv.ParseInt(secSplit[0], 10, 64)
if err != nil || sec > maxUnixCommitDate || sec < 0 {
- sec = git.FallbackTimeValue.Unix()
+ sec = fallbackTimeValue.Unix()
}
author.Date = &timestamppb.Timestamp{Seconds: sec}
diff --git a/internal/git/proto.go b/internal/git/proto.go
index 97dac733b..1e13a02ad 100644
--- a/internal/git/proto.go
+++ b/internal/git/proto.go
@@ -3,14 +3,8 @@ package git
import (
"bytes"
"fmt"
- "time"
)
-// FallbackTimeValue is the value returned by `SafeTimeParse` in case it
-// encounters a parse error. It's the maximum time value possible in golang.
-// See https://gitlab.com/gitlab-org/gitaly/issues/556#note_40289573
-var FallbackTimeValue = time.Unix(1<<63-62135596801, 999999999)
-
func validateRevision(revision []byte, allowEmpty bool) error {
if !allowEmpty && len(revision) == 0 {
return fmt.Errorf("empty revision")