diff options
-rw-r--r-- | cmd/gitaly-git2go/merge.go | 11 | ||||
-rw-r--r-- | cmd/gitaly-git2go/merge_test.go | 4 | ||||
-rw-r--r-- | internal/git2go/merge.go | 3 |
3 files changed, 8 insertions, 10 deletions
diff --git a/cmd/gitaly-git2go/merge.go b/cmd/gitaly-git2go/merge.go index 8040ca4bc..3f07a51ab 100644 --- a/cmd/gitaly-git2go/merge.go +++ b/cmd/gitaly-git2go/merge.go @@ -59,13 +59,8 @@ func (cmd *mergeSubcommand) Run() error { return err } - var date time.Time = time.Now() - if request.AuthorDate != "" { - var err error - date, err = time.Parse("Mon Jan 2 15:04:05 2006 -0700", request.AuthorDate) - if err != nil { - return err - } + if request.AuthorDate.IsZero() { + request.AuthorDate = time.Now() } repo, err := git.OpenRepository(request.Repository) @@ -100,7 +95,7 @@ func (cmd *mergeSubcommand) Run() error { committer := git.Signature{ Name: sanitizeSignatureInfo(request.AuthorName), Email: sanitizeSignatureInfo(request.AuthorMail), - When: date, + When: request.AuthorDate, } commit, err := repo.CreateCommitFromIds("", &committer, &committer, request.Message, tree, ours.Id(), theirs.Id()) diff --git a/cmd/gitaly-git2go/merge_test.go b/cmd/gitaly-git2go/merge_test.go index 11e9d87e3..c5ae2a5d9 100644 --- a/cmd/gitaly-git2go/merge_test.go +++ b/cmd/gitaly-git2go/merge_test.go @@ -213,6 +213,8 @@ func TestMergeTrees(t *testing.T) { ours := buildCommit(t, repoPath, base, tc.ours) theirs := buildCommit(t, repoPath, base, tc.theirs) + authorDate := time.Date(2020, 7, 30, 7, 45, 50, 0, time.FixedZone("UTC+2", +2*60*60)) + t.Run(tc.desc, func(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() @@ -221,7 +223,7 @@ func TestMergeTrees(t *testing.T) { Repository: repoPath, AuthorName: "John Doe", AuthorMail: "john.doe@example.com", - AuthorDate: "Thu Jul 30 07:45:50 2020 +0200", + AuthorDate: authorDate, Message: "Merge message", Ours: ours.String(), Theirs: theirs.String(), diff --git a/internal/git2go/merge.go b/internal/git2go/merge.go index 946037812..b901353af 100644 --- a/internal/git2go/merge.go +++ b/internal/git2go/merge.go @@ -10,6 +10,7 @@ import ( "os/exec" "path" "strings" + "time" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" @@ -29,7 +30,7 @@ type MergeCommand struct { // AuthorMail is the author mail of merge commit. AuthorMail string `json:"author_mail"` // AuthorDate is the auithor date of merge commit. - AuthorDate string `json:"author_date"` + AuthorDate time.Time `json:"author_date"` // Message is the message to be used for the merge commit. Message string `json:"message"` // Ours is the commit that is to be merged into theirs. |