diff options
author | Roger Meier <r.meier@siemens.com> | 2019-11-05 00:00:57 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-11-05 00:00:57 +0300 |
commit | f5e796192cf2d6d0b3ff3b4f5825ddbb0ddde1de (patch) | |
tree | 4598b5fbb5624dbf32873e0c30f49fe9c878c87a /internal | |
parent | e9f9183a3228241d3b4ab352425d3d68890fcf02 (diff) |
Add tagger and timezone
Diffstat (limited to 'internal')
-rw-r--r-- | internal/git/log/commit.go | 4 | ||||
-rw-r--r-- | internal/git/log/commit_test.go | 14 | ||||
-rw-r--r-- | internal/git/log/tag.go | 8 | ||||
-rw-r--r-- | internal/git/log/tag_test.go | 8 | ||||
-rw-r--r-- | internal/service/commit/between_test.go | 52 | ||||
-rw-r--r-- | internal/service/commit/commits_by_message_test.go | 14 | ||||
-rw-r--r-- | internal/service/commit/find_all_commits_test.go | 14 | ||||
-rw-r--r-- | internal/service/commit/find_commit_test.go | 112 | ||||
-rw-r--r-- | internal/service/commit/find_commits_test.go | 56 | ||||
-rw-r--r-- | internal/service/commit/last_commit_for_path_test.go | 14 | ||||
-rw-r--r-- | internal/service/commit/testhelper_test.go | 7 | ||||
-rw-r--r-- | internal/service/ref/refs_test.go | 154 | ||||
-rw-r--r-- | internal/service/ref/testhelper_test.go | 42 | ||||
-rw-r--r-- | internal/service/ref/util.go | 14 | ||||
-rw-r--r-- | internal/service/ref/util_test.go | 56 | ||||
-rw-r--r-- | internal/testhelper/testhelper.go | 5 |
16 files changed, 375 insertions, 199 deletions
diff --git a/internal/git/log/commit.go b/internal/git/log/commit.go index e0b7d30db..3fd7a4cfd 100644 --- a/internal/git/log/commit.go +++ b/internal/git/log/commit.go @@ -158,6 +158,10 @@ func parseCommitAuthor(line string) *gitalypb.CommitAuthor { author.Date = ×tamp.Timestamp{Seconds: sec} + if len(secSplit) == 2 { + author.Timezone = []byte(secSplit[1]) + } + return author } diff --git a/internal/git/log/commit_test.go b/internal/git/log/commit_test.go index a70efdb36..120604859 100644 --- a/internal/git/log/commit_test.go +++ b/internal/git/log/commit_test.go @@ -71,9 +71,10 @@ func TestParseRawCommit(t *testing.T) { out: &gitalypb.GitCommit{ Id: info.Oid, Author: &gitalypb.CommitAuthor{ - Name: []byte("Jane Doe"), - Email: []byte("janedoe@example.com"), - Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Name: []byte("Jane Doe"), + Email: []byte("janedoe@example.com"), + Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Timezone: []byte("+0200"), }, }, }, @@ -83,9 +84,10 @@ func TestParseRawCommit(t *testing.T) { out: &gitalypb.GitCommit{ Id: info.Oid, Author: &gitalypb.CommitAuthor{ - Name: []byte("Jane Doe"), - Email: []byte("janedoe@example.com"), - Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Name: []byte("Jane Doe"), + Email: []byte("janedoe@example.com"), + Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Timezone: []byte("+0200"), }, }, }, diff --git a/internal/git/log/tag.go b/internal/git/log/tag.go index fca94292d..52c340673 100644 --- a/internal/git/log/tag.go +++ b/internal/git/log/tag.go @@ -44,6 +44,8 @@ func GetTagCatfile(c *catfile.Batch, tagID, tagName string) (*gitalypb.Tag, erro type tagHeader struct { oid string tagType string + tag string + tagger string } func splitRawTag(r io.Reader) (*tagHeader, []byte, error) { @@ -75,6 +77,10 @@ func splitRawTag(r io.Reader) (*tagHeader, []byte, error) { header.oid = value case "type": header.tagType = value + case "tag": + header.tag = value + case "tagger": + header.tagger = value } } @@ -108,6 +114,8 @@ func buildAnnotatedTag(b *catfile.Batch, tagID, name string, header *tagHeader, } } + tag.Tagger = parseCommitAuthor(header.tagger) + return tag, nil } diff --git a/internal/git/log/tag_test.go b/internal/git/log/tag_test.go index 13ef06166..daa8540b4 100644 --- a/internal/git/log/tag_test.go +++ b/internal/git/log/tag_test.go @@ -69,6 +69,8 @@ func TestSplitRawTag(t *testing.T) { header: tagHeader{ oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2", tagType: "commit", + tag: "v2.6.16.28", + tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200", }, body: nil, }, @@ -78,6 +80,8 @@ func TestSplitRawTag(t *testing.T) { header: tagHeader{ oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2", tagType: "commit", + tag: "v2.6.16.28", + tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200", }, body: []byte("message"), }, @@ -87,6 +91,8 @@ func TestSplitRawTag(t *testing.T) { header: tagHeader{ oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2", tagType: "commit", + tag: "v2.6.16.28", + tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200", }, body: []byte{}, }, @@ -96,6 +102,8 @@ func TestSplitRawTag(t *testing.T) { header: tagHeader{ oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2", tagType: "commit", + tag: "v2.6.16.28", + tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200", }, body: []byte("Hello world\n\nThis is a message"), }, diff --git a/internal/service/commit/between_test.go b/internal/service/commit/between_test.go index cc4d14c64..78f678aaf 100644 --- a/internal/service/commit/between_test.go +++ b/internal/service/commit/between_test.go @@ -32,14 +32,16 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -52,14 +54,16 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Subject: []byte("Update README.md to include `Usage in testing and development`"), Body: []byte("Update README.md to include `Usage in testing and development`"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Luke \"Jared\" Bennett"), - Email: []byte("lbennett@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1491905339}, + Name: []byte("Luke \"Jared\" Bennett"), + Email: []byte("lbennett@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1491905339}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Luke \"Jared\" Bennett"), - Email: []byte("lbennett@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1491905339}, + Name: []byte("Luke \"Jared\" Bennett"), + Email: []byte("lbennett@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1491905339}, + Timezone: []byte("+0000"), }, ParentIds: []string{"b83d6e391c22777fca1ed3012fce84f633d7fed0"}, BodySize: 62, @@ -69,14 +73,16 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Subject: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'"), Body: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'\r\n\r\nUpdate README.md to include `Usage in testing and development`\r\n\r\nSee merge request !21"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Sean McGivern"), - Email: []byte("sean@mcgivern.me.uk"), - Date: ×tamp.Timestamp{Seconds: 1491906794}, + Name: []byte("Sean McGivern"), + Email: []byte("sean@mcgivern.me.uk"), + Date: ×tamp.Timestamp{Seconds: 1491906794}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Sean McGivern"), - Email: []byte("sean@mcgivern.me.uk"), - Date: ×tamp.Timestamp{Seconds: 1491906794}, + Name: []byte("Sean McGivern"), + Email: []byte("sean@mcgivern.me.uk"), + Date: ×tamp.Timestamp{Seconds: 1491906794}, + Timezone: []byte("+0000"), }, ParentIds: []string{ "b83d6e391c22777fca1ed3012fce84f633d7fed0", @@ -92,12 +98,14 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Name: []byte("Alejandro Rodríguez"), Email: []byte("alejorro70@gmail.com"), // Not the actual commit date, but the biggest we can represent - Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Alejandro Rodríguez"), - Email: []byte("alejorro70@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Name: []byte("Alejandro Rodríguez"), + Email: []byte("alejorro70@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, + Timezone: []byte("+0000"), }, ParentIds: []string{"e63f41fe459e62e1228fcef60d7189127aeba95a"}, BodySize: 18, diff --git a/internal/service/commit/commits_by_message_test.go b/internal/service/commit/commits_by_message_test.go index 40fb232d6..fd6f43ef7 100644 --- a/internal/service/commit/commits_by_message_test.go +++ b/internal/service/commit/commits_by_message_test.go @@ -86,14 +86,16 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { Subject: []byte("Files, encoding and much more"), Body: []byte("Files, encoding and much more\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488896}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488896}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488896}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488896}, + Timezone: []byte("+0200"), }, ParentIds: []string{"cfe32cf61b73a0d5e9f13e774abde7ff789b1660"}, BodySize: 98, diff --git a/internal/service/commit/find_all_commits_test.go b/internal/service/commit/find_all_commits_test.go index 629207133..e79b1ae45 100644 --- a/internal/service/commit/find_all_commits_test.go +++ b/internal/service/commit/find_all_commits_test.go @@ -159,14 +159,16 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { Subject: []byte("Initial commit"), Body: []byte("Initial commit\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488198}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488198}, + Timezone: []byte("-0800"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488198}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488198}, + Timezone: []byte("-0800"), }, ParentIds: nil, BodySize: 15, diff --git a/internal/service/commit/find_commit_test.go b/internal/service/commit/find_commit_test.go index 08cc730c8..dcfa5d019 100644 --- a/internal/service/commit/find_commit_test.go +++ b/internal/service/commit/find_commit_test.go @@ -57,14 +57,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: []byte("adds bar folder and branch-test text file to check Repository merged_to_root_ref method"), Body: []byte("adds bar folder and branch-test text file to check Repository merged_to_root_ref method\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("tiagonbotelho"), - Email: []byte("tiagonbotelho@hotmail.com"), - Date: ×tamp.Timestamp{Seconds: 1474470806}, + Name: []byte("tiagonbotelho"), + Email: []byte("tiagonbotelho@hotmail.com"), + Date: ×tamp.Timestamp{Seconds: 1474470806}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("tiagonbotelho"), - Email: []byte("tiagonbotelho@hotmail.com"), - Date: ×tamp.Timestamp{Seconds: 1474470806}, + Name: []byte("tiagonbotelho"), + Email: []byte("tiagonbotelho@hotmail.com"), + Date: ×tamp.Timestamp{Seconds: 1474470806}, + Timezone: []byte("+0100"), }, ParentIds: []string{"1b12f15a11fc6e62177bef08f47bc7b5ce50b141"}, BodySize: 88, @@ -78,14 +80,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: []byte("More submodules"), Body: []byte("More submodules\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, ParentIds: []string{"d14d6c0abdd253381df51a723d58691b2ee1ab08"}, BodySize: 84, @@ -99,14 +103,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -123,14 +129,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: []byte("Initial commit"), Body: []byte("Initial commit\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488198}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488198}, + Timezone: []byte("-0800"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488198}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488198}, + Timezone: []byte("-0800"), }, ParentIds: nil, BodySize: 15, @@ -144,14 +152,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: windows1251Message[:len(windows1251Message)-1], Body: windows1251Message, Author: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1512132977}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1512132977}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1512132977}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1512132977}, + Timezone: []byte("+0100"), }, ParentIds: []string{"e63f41fe459e62e1228fcef60d7189127aeba95a"}, BodySize: 49, @@ -165,14 +175,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Subject: []byte("Hello\xf0world"), Body: []byte("Hello\xf0world\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1517328273}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1517328273}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1517328273}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1517328273}, + Timezone: []byte("+0100"), }, ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"}, BodySize: 12, @@ -185,14 +197,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { Id: bigCommitID, Subject: []byte("An empty commit with REALLY BIG message"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Scrooge McDuck"), - Email: []byte("scrooge@mcduck.com"), - Date: ×tamp.Timestamp{Seconds: bigCommit.Author.Date.Seconds}, + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: bigCommit.Author.Date.Seconds}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Scrooge McDuck"), - Email: []byte("scrooge@mcduck.com"), - Date: ×tamp.Timestamp{Seconds: bigCommit.Committer.Date.Seconds}, + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: bigCommit.Committer.Date.Seconds}, + Timezone: []byte("+0100"), }, ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"}, Body: []byte(bigMessage[:helper.MaxCommitOrTagMessageSize]), @@ -207,14 +221,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { 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: &gitalypb.CommitAuthor{ - Name: []byte("Ruben Davila"), - Email: []byte("rdavila84@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1523247267}, + Name: []byte("Ruben Davila"), + Email: []byte("rdavila84@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1523247267}, + Timezone: []byte("-0500"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1527855450}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1527855450}, + Timezone: []byte("+0200"), }, ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"}, BodySize: 100, diff --git a/internal/service/commit/find_commits_test.go b/internal/service/commit/find_commits_test.go index dd4c4d58f..3dff50d09 100644 --- a/internal/service/commit/find_commits_test.go +++ b/internal/service/commit/find_commits_test.go @@ -40,14 +40,16 @@ func TestFindCommitsFields(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0000"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -63,14 +65,16 @@ func TestFindCommitsFields(t *testing.T) { Subject: windows1251Message[:len(windows1251Message)-1], Body: windows1251Message, Author: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1512132977}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1512132977}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1512132977}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1512132977}, + Timezone: []byte("+0100"), }, ParentIds: []string{"e63f41fe459e62e1228fcef60d7189127aeba95a"}, BodySize: 49, @@ -83,14 +87,16 @@ func TestFindCommitsFields(t *testing.T) { Subject: []byte("Hello\xf0world"), Body: []byte("Hello\xf0world\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1517328273}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1517328273}, + Timezone: []byte("+0100"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1517328273}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1517328273}, + Timezone: []byte("+0100"), }, ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"}, BodySize: 12, @@ -103,14 +109,16 @@ func TestFindCommitsFields(t *testing.T) { 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: &gitalypb.CommitAuthor{ - Name: []byte("Ruben Davila"), - Email: []byte("rdavila84@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1523247267}, + Name: []byte("Ruben Davila"), + Email: []byte("rdavila84@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1523247267}, + Timezone: []byte("-0500"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Jacob Vosmaer"), - Email: []byte("jacob@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1527855450}, + Name: []byte("Jacob Vosmaer"), + Email: []byte("jacob@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1527855450}, + Timezone: []byte("+0200"), }, ParentIds: []string{"60ecb67744cb56576c30214ff52294f8ce2def98"}, BodySize: 100, diff --git a/internal/service/commit/last_commit_for_path_test.go b/internal/service/commit/last_commit_for_path_test.go index ccf581672..d027c6df2 100644 --- a/internal/service/commit/last_commit_for_path_test.go +++ b/internal/service/commit/last_commit_for_path_test.go @@ -26,14 +26,16 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) { Subject: []byte("Change some files"), Body: []byte("Change some files\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491451}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491451}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491451}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491451}, + Timezone: []byte("+0200"), }, ParentIds: []string{"6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"}, BodySize: 86, diff --git a/internal/service/commit/testhelper_test.go b/internal/service/commit/testhelper_test.go index 4137e9d6c..2c140392a 100644 --- a/internal/service/commit/testhelper_test.go +++ b/internal/service/commit/testhelper_test.go @@ -63,8 +63,9 @@ func newCommitServiceClient(t testing.TB, serviceSocketPath string) (gitalypb.Co func dummyCommitAuthor(ts int64) *gitalypb.CommitAuthor { return &gitalypb.CommitAuthor{ - Name: []byte("Ahmad Sherif"), - Email: []byte("ahmad+gitlab-test@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: ts}, + Name: []byte("Ahmad Sherif"), + Email: []byte("ahmad+gitlab-test@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: ts}, + Timezone: []byte("+0200"), } } diff --git a/internal/service/ref/refs_test.go b/internal/service/ref/refs_test.go index c50631825..a43b3161f 100644 --- a/internal/service/ref/refs_test.go +++ b/internal/service/ref/refs_test.go @@ -447,14 +447,16 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { Subject: []byte("More submodules"), Body: []byte("More submodules\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, ParentIds: []string{"d14d6c0abdd253381df51a723d58691b2ee1ab08"}, BodySize: 84, @@ -516,6 +518,12 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("commit tag with a commit sha as the name"), MessageSize: 40, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("tag-of-tag"), @@ -523,6 +531,12 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("tag of a tag"), MessageSize: 12, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("v1.0.0"), @@ -530,6 +544,12 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("Release"), MessageSize: 7, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491299}, + Timezone: []byte("+0200"), + }, }, { Name: []byte("v1.1.0"), @@ -539,26 +559,40 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { Subject: []byte("Add submodule from gitlab.com"), Body: []byte("Add submodule from gitlab.com\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, ParentIds: []string{"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"}, BodySize: 98, }, Message: []byte("Version 1.1.0"), MessageSize: 13, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393505709}, + Timezone: []byte("+0200"), + }, }, { Name: []byte("v1.2.0"), Id: string(annotatedTagID), Message: []byte("Blob tag"), MessageSize: 8, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("v1.3.0"), @@ -585,6 +619,12 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { Message: []byte(bigMessage[:helper.MaxCommitOrTagMessageSize]), MessageSize: int64(len(bigMessage)), TargetCommit: gitCommit, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, } @@ -659,6 +699,12 @@ func TestFindAllTagNestedTags(t *testing.T) { Id: string(tagID), Message: []byte(tagMessage), MessageSize: int64(len([]byte(tagMessage))), + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, } // only expect the TargetCommit to be populated if it is a commit and if its less than 10 tags deep @@ -913,14 +959,16 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) { BodySize: 98, ParentIds: []string{"cfe32cf61b73a0d5e9f13e774abde7ff789b1660"}, Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488896}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488896}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393488896}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393488896}, + Timezone: []byte("+0200"), }, }, } @@ -1293,14 +1341,16 @@ func TestSuccessfulFindTagRequest(t *testing.T) { Subject: []byte("More submodules"), Body: []byte("More submodules\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491261}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491261}, + Timezone: []byte("+0200"), }, ParentIds: []string{"d14d6c0abdd253381df51a723d58691b2ee1ab08"}, BodySize: 84, @@ -1347,6 +1397,12 @@ func TestSuccessfulFindTagRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("commit tag with a commit sha as the name"), MessageSize: 40, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("tag-of-tag"), @@ -1354,6 +1410,12 @@ func TestSuccessfulFindTagRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("tag of a tag"), MessageSize: 12, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("v1.0.0"), @@ -1361,6 +1423,12 @@ func TestSuccessfulFindTagRequest(t *testing.T) { TargetCommit: gitCommit, Message: []byte("Release"), MessageSize: 7, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491299}, + Timezone: []byte("+0200"), + }, }, { Name: []byte("v1.1.0"), @@ -1370,26 +1438,40 @@ func TestSuccessfulFindTagRequest(t *testing.T) { Subject: []byte("Add submodule from gitlab.com"), Body: []byte("Add submodule from gitlab.com\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, ParentIds: []string{"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"}, BodySize: 98, }, Message: []byte("Version 1.1.0"), MessageSize: 13, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393505709}, + Timezone: []byte("+0200"), + }, }, { Name: []byte("v1.2.0"), Id: string(annotatedTagID), Message: []byte("Blob tag"), MessageSize: 8, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, { Name: []byte("v1.3.0"), @@ -1416,6 +1498,12 @@ func TestSuccessfulFindTagRequest(t *testing.T) { Message: []byte(bigMessage[:helper.MaxCommitOrTagMessageSize]), MessageSize: int64(len(bigMessage)), TargetCommit: gitCommit, + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, }, } @@ -1496,6 +1584,12 @@ func TestFindTagNestedTag(t *testing.T) { Id: string(tagID), Message: []byte(tagMessage), MessageSize: int64(len([]byte(tagMessage))), + Tagger: &gitalypb.CommitAuthor{ + Name: []byte("Scrooge McDuck"), + Email: []byte("scrooge@mcduck.com"), + Date: ×tamp.Timestamp{Seconds: 1572776879}, + Timezone: []byte("+0100"), + }, } // only expect the TargetCommit to be populated if it is a commit and if its less than 10 tags deep if info.Type == "commit" && tc.depth < log.MaxTagReferenceDepth { diff --git a/internal/service/ref/testhelper_test.go b/internal/service/ref/testhelper_test.go index 7c68f8416..609150b26 100644 --- a/internal/service/ref/testhelper_test.go +++ b/internal/service/ref/testhelper_test.go @@ -26,14 +26,16 @@ var ( ParentIds: []string{"6907208d755b60ebeacb2e9dfea74c92c3449a1f", "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e"}, Subject: []byte("Merge branch 'add-directory-with-space' into 'master'"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Stan Hu"), - Email: []byte("stanhu@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1471558878}, + Name: []byte("Stan Hu"), + Email: []byte("stanhu@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1471558878}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Stan Hu"), - Email: []byte("stanhu@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1471558878}, + Name: []byte("Stan Hu"), + Email: []byte("stanhu@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1471558878}, + Timezone: []byte("+0000"), }, }, "refs/heads/improve/awesome": { @@ -43,14 +45,16 @@ var ( BodySize: 98, ParentIds: []string{"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"}, Author: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Dmitriy Zaporozhets"), - Email: []byte("dmitriy.zaporozhets@gmail.com"), - Date: ×tamp.Timestamp{Seconds: 1393491698}, + Name: []byte("Dmitriy Zaporozhets"), + Email: []byte("dmitriy.zaporozhets@gmail.com"), + Date: ×tamp.Timestamp{Seconds: 1393491698}, + Timezone: []byte("+0200"), }, }, "refs/heads/'test'": { @@ -60,14 +64,16 @@ var ( BodySize: 317, ParentIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e", "4cd80ccab63c82b4bad16faa5193fbd2aa06df40"}, Author: &gitalypb.CommitAuthor{ - Name: []byte("Sytse Sijbrandij"), - Email: []byte("sytse@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1420925009}, + Name: []byte("Sytse Sijbrandij"), + Email: []byte("sytse@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1420925009}, + Timezone: []byte("+0000"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Sytse Sijbrandij"), - Email: []byte("sytse@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1420925009}, + Name: []byte("Sytse Sijbrandij"), + Email: []byte("sytse@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1420925009}, + Timezone: []byte("+0000"), }, }, } diff --git a/internal/service/ref/util.go b/internal/service/ref/util.go index d4b1120eb..eecc0c49d 100644 --- a/internal/service/ref/util.go +++ b/internal/service/ref/util.go @@ -34,17 +34,19 @@ func buildLocalBranch(name []byte, target *gitalypb.GitCommit) *gitalypb.FindLoc if author := target.Author; author != nil { response.CommitAuthor = &gitalypb.FindLocalBranchCommitAuthor{ - Name: author.Name, - Email: author.Email, - Date: author.Date, + Name: author.Name, + Email: author.Email, + Date: author.Date, + Timezone: author.Timezone, } } if committer := target.Committer; committer != nil { response.CommitCommitter = &gitalypb.FindLocalBranchCommitAuthor{ - Name: committer.Name, - Email: committer.Email, - Date: committer.Date, + Name: committer.Name, + Email: committer.Email, + Date: committer.Date, + Timezone: committer.Timezone, } } diff --git a/internal/service/ref/util_test.go b/internal/service/ref/util_test.go index 7a9d40d29..ac09bb8cc 100644 --- a/internal/service/ref/util_test.go +++ b/internal/service/ref/util_test.go @@ -21,14 +21,16 @@ func TestBuildLocalBranch(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, Committer: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -41,14 +43,16 @@ func TestBuildLocalBranch(t *testing.T) { CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, }, }, @@ -59,9 +63,10 @@ func TestBuildLocalBranch(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Committer: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -75,9 +80,10 @@ func TestBuildLocalBranch(t *testing.T) { CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), CommitAuthor: nil, CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, }, }, @@ -88,9 +94,10 @@ func TestBuildLocalBranch(t *testing.T) { Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), Author: &gitalypb.CommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, ParentIds: []string{ "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", @@ -103,9 +110,10 @@ func TestBuildLocalBranch(t *testing.T) { CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{ - Name: []byte("Job van der Voort"), - Email: []byte("job@gitlab.com"), - Date: ×tamp.Timestamp{Seconds: 1474987066}, + Name: []byte("Job van der Voort"), + Email: []byte("job@gitlab.com"), + Date: ×tamp.Timestamp{Seconds: 1474987066}, + Timezone: []byte("+0200"), }, CommitCommitter: nil, }, diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index f7809b2ee..d547d865a 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -165,7 +165,12 @@ func MustRunCommand(t testing.TB, stdin io.Reader, name string, args ...string) cmd := exec.Command(name, args...) if name == "git" { + cmd.Env = os.Environ() cmd.Env = append(command.GitEnv, cmd.Env...) + cmd.Env = append(cmd.Env, + "GIT_AUTHOR_DATE=1572776879 +0100", + "GIT_COMMITTER_DATE=1572776879 +0100", + ) } if stdin != nil { |