From 16daf112d6cfe2c87d8837382a00d88aa8c0ff5c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 14 Sep 2022 12:12:34 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/commit.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/models/commit.rb') 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 -- cgit v1.2.1