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>2020-09-17 10:29:53 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-09-21 11:44:48 +0300
commit295c3b7c65a88205a4aef33e6ad0e625d7ba3123 (patch)
treea30e849d9173ffd4795c041e9ad25398f068edf5 /cmd/gitaly-git2go
parent70e3be10d7e3181d342ed3bfa9346b922f8a9570 (diff)
git2go: Pass author date to merge command as `time.Time`
Now that we're using a JSON-serialized structure to pass data to gitaly-git2go, we can use more typing. So let's convert from using a time string to passing around `time.Time` instead.
Diffstat (limited to 'cmd/gitaly-git2go')
-rw-r--r--cmd/gitaly-git2go/merge.go11
-rw-r--r--cmd/gitaly-git2go/merge_test.go4
2 files changed, 6 insertions, 9 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(),