diff options
author | John Cai <jcai@gitlab.com> | 2019-11-05 00:00:58 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-11-05 00:00:58 +0300 |
commit | 54e803c183039d19a5a6e0d7e0f730fb74c758e7 (patch) | |
tree | 4598b5fbb5624dbf32873e0c30f49fe9c878c87a /internal/git | |
parent | e9f9183a3228241d3b4ab352425d3d68890fcf02 (diff) | |
parent | f5e796192cf2d6d0b3ff3b4f5825ddbb0ddde1de (diff) |
Merge branch 'feat/tz-and-tagger' into 'master'
Add tagger and timezone
See merge request gitlab-org/gitaly!1594
Diffstat (limited to 'internal/git')
-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 |
4 files changed, 28 insertions, 6 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"), }, |