summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-14 12:12:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-14 12:12:34 +0000
commit16daf112d6cfe2c87d8837382a00d88aa8c0ff5c (patch)
tree017d43acafea2928550fe7c8fdbb7cf36335ba9f /app/models/commit.rb
parent3cb798d80b6b5235b5f5febaaacef410e75c2963 (diff)
downloadgitlab-ce-16daf112d6cfe2c87d8837382a00d88aa8c0ff5c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index bd60f02b532..54de45ebba7 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -133,6 +133,22 @@ class Commit
def parent_class
::Project
end
+
+ def build_from_sidekiq_hash(project, hash)
+ hash = hash.dup
+ date_suffix = '_date'
+
+ # When processing Sidekiq payloads various timestamps are stored as Strings.
+ # Commit in turn expects Time-like instances upon input, so we have to
+ # manually parse these values.
+ hash.each do |key, value|
+ if key.to_s.end_with?(date_suffix) && value.is_a?(String)
+ hash[key] = Time.zone.parse(value)
+ end
+ end
+
+ from_hash(hash, project)
+ end
end
attr_accessor :raw