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:
authorKim Carlbäcker <kim.carlbacker@gmail.com>2018-06-01 16:59:05 +0300
committerKim Carlbäcker <kim.carlbacker@gmail.com>2018-06-01 16:59:05 +0300
commit90d35a6d2782e70843cb8e79a4c9a34fa613d8c4 (patch)
treee566cfb3a9e0e485a12ca0939f999494aff1eff6
parenta44cd4a1a9322c8f1f90186eaf5b031a56e9019d (diff)
parente6db52531ea0436188f9749abff4a5ad418d9fc5 (diff)
Merge branch 'fix-commit-committer-fields' into 'master'
Fix committer bug in go-git adapter See merge request gitlab-org/gitaly!748
-rw-r--r--changelogs/unreleased/fix-commit-committer-fields.yml5
-rw-r--r--internal/adapters/gogit/commit.go4
-rw-r--r--internal/adapters/gogit/commit_test.go20
-rw-r--r--internal/service/commit/find_commit_test.go21
-rw-r--r--internal/service/commit/find_commits_test.go20
5 files changed, 68 insertions, 2 deletions
diff --git a/changelogs/unreleased/fix-commit-committer-fields.yml b/changelogs/unreleased/fix-commit-committer-fields.yml
new file mode 100644
index 000000000..8b8df18da
--- /dev/null
+++ b/changelogs/unreleased/fix-commit-committer-fields.yml
@@ -0,0 +1,5 @@
+---
+title: Fix committer bug in go-git adapter
+merge_request: 748
+author:
+type: fixed
diff --git a/internal/adapters/gogit/commit.go b/internal/adapters/gogit/commit.go
index 2d044b96b..64fe87eb3 100644
--- a/internal/adapters/gogit/commit.go
+++ b/internal/adapters/gogit/commit.go
@@ -57,8 +57,8 @@ func commitToProtoCommit(commit *object.Commit) *pb.GitCommit {
}
committer := pb.CommitAuthor{
Name: []byte(commit.Committer.Name),
- Email: []byte(commit.Author.Email),
- Date: &timestamp.Timestamp{Seconds: commit.Author.When.Unix()},
+ Email: []byte(commit.Committer.Email),
+ Date: &timestamp.Timestamp{Seconds: commit.Committer.When.Unix()},
}
byteBody := []byte(body)
diff --git a/internal/adapters/gogit/commit_test.go b/internal/adapters/gogit/commit_test.go
index a363f4ddb..9fad9f915 100644
--- a/internal/adapters/gogit/commit_test.go
+++ b/internal/adapters/gogit/commit_test.go
@@ -78,6 +78,26 @@ func TestFindCommit(t *testing.T) {
BodySize: 12,
},
},
+ {
+ revision: "author-committer-different",
+ commit: &pb.GitCommit{
+ Id: "77e835ef0856f33c4f0982f84d10bdb0567fe440",
+ Subject: []byte("Add file larger than 1 mb"),
+ Body: []byte("Add file larger than 1 mb\n\nIn order to test Max File Size push rule we need a file larger than 1 MB\n"),
+ Author: &pb.CommitAuthor{
+ Name: []byte("Ruben Davila"),
+ Email: []byte("rdavila84@gmail.com"),
+ Date: &timestamp.Timestamp{Seconds: 1523247267},
+ },
+ Committer: &pb.CommitAuthor{
+ Name: []byte("Jacob Vosmaer"),
+ Email: []byte("jacob@gitlab.com"),
+ Date: &timestamp.Timestamp{Seconds: 1527855450},
+ },
+ ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"},
+ BodySize: 100,
+ },
+ },
}
for _, tc := range testCases {
diff --git a/internal/service/commit/find_commit_test.go b/internal/service/commit/find_commit_test.go
index 6e8b522ec..b0874a1df 100644
--- a/internal/service/commit/find_commit_test.go
+++ b/internal/service/commit/find_commit_test.go
@@ -197,6 +197,27 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
},
},
{
+ description: "with different author and committer",
+ revision: "77e835ef0856f33c4f0982f84d10bdb0567fe440",
+ commit: &pb.GitCommit{
+ Id: "77e835ef0856f33c4f0982f84d10bdb0567fe440",
+ Subject: []byte("Add file larger than 1 mb"),
+ Body: []byte("Add file larger than 1 mb\n\nIn order to test Max File Size push rule we need a file larger than 1 MB\n"),
+ Author: &pb.CommitAuthor{
+ Name: []byte("Ruben Davila"),
+ Email: []byte("rdavila84@gmail.com"),
+ Date: &timestamp.Timestamp{Seconds: 1523247267},
+ },
+ Committer: &pb.CommitAuthor{
+ Name: []byte("Jacob Vosmaer"),
+ Email: []byte("jacob@gitlab.com"),
+ Date: &timestamp.Timestamp{Seconds: 1527855450},
+ },
+ ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"},
+ BodySize: 100,
+ },
+ },
+ {
description: "With a non-existing ref name",
revision: "this-doesnt-exists",
commit: nil,
diff --git a/internal/service/commit/find_commits_test.go b/internal/service/commit/find_commits_test.go
index b72f81d5d..d89a437f6 100644
--- a/internal/service/commit/find_commits_test.go
+++ b/internal/service/commit/find_commits_test.go
@@ -97,6 +97,26 @@ func TestFindCommitsFields(t *testing.T) {
BodySize: 12,
},
},
+ {
+ id: "77e835ef0856f33c4f0982f84d10bdb0567fe440",
+ commit: &pb.GitCommit{
+ Id: "77e835ef0856f33c4f0982f84d10bdb0567fe440",
+ Subject: []byte("Add file larger than 1 mb"),
+ Body: []byte("Add file larger than 1 mb\n\nIn order to test Max File Size push rule we need a file larger than 1 MB\n"),
+ Author: &pb.CommitAuthor{
+ Name: []byte("Ruben Davila"),
+ Email: []byte("rdavila84@gmail.com"),
+ Date: &timestamp.Timestamp{Seconds: 1523247267},
+ },
+ Committer: &pb.CommitAuthor{
+ Name: []byte("Jacob Vosmaer"),
+ Email: []byte("jacob@gitlab.com"),
+ Date: &timestamp.Timestamp{Seconds: 1527855450},
+ },
+ ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"},
+ BodySize: 100,
+ },
+ },
}
for _, tc := range testCases {