diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 21:06:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 21:06:49 +0300 |
commit | ab7cf450ba19cf80b9534f25dc707b33845e3014 (patch) | |
tree | bbfa6aba83c48aea68d79c4179ce576b6eec326d /lib/gitlab/git/commit.rb | |
parent | 4204cf308596e0e26f578a6e2da88f49c0f4aad9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/git/commit.rb')
-rw-r--r-- | lib/gitlab/git/commit.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 6210223917b..b2dc9a8a3c8 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -370,15 +370,26 @@ module Gitlab # subject from the message to make it clearer when there's one # available but not the other. @message = message_from_gitaly_body - @authored_date = Time.at(commit.author.date.seconds).utc + @authored_date = init_date_from_gitaly(commit.author) @author_name = commit.author.name.dup @author_email = commit.author.email.dup - @committed_date = Time.at(commit.committer.date.seconds).utc + + @committed_date = init_date_from_gitaly(commit.committer) @committer_name = commit.committer.name.dup @committer_email = commit.committer.email.dup @parent_ids = Array(commit.parent_ids) end + # Gitaly provides a UNIX timestamp in author.date.seconds, and a timezone + # offset in author.timezone. If the latter isn't present, assume UTC. + def init_date_from_gitaly(author) + if author.timezone.present? + Time.strptime("#{author.date.seconds} #{author.timezone}", '%s %z') + else + Time.at(author.date.seconds).utc + end + end + def serialize_keys SERIALIZE_KEYS end |