diff options
Diffstat (limited to 'app/models/merge_request_diff_commit.rb')
-rw-r--r-- | app/models/merge_request_diff_commit.rb | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/app/models/merge_request_diff_commit.rb b/app/models/merge_request_diff_commit.rb index b897bbc8cf5..aa41a68f184 100644 --- a/app/models/merge_request_diff_commit.rb +++ b/app/models/merge_request_diff_commit.rb @@ -2,6 +2,7 @@ class MergeRequestDiffCommit < ApplicationRecord include ShaAttribute + include CachedCommit belongs_to :merge_request_diff @@ -9,8 +10,6 @@ class MergeRequestDiffCommit < ApplicationRecord alias_attribute :id, :sha def self.create_bulk(merge_request_diff_id, commits) - sha_attribute = Gitlab::Database::ShaAttribute.new - rows = commits.map.with_index do |commit, index| # See #parent_ids. commit_hash = commit.to_hash.except(:parent_ids) @@ -19,7 +18,7 @@ class MergeRequestDiffCommit < ApplicationRecord commit_hash.merge( merge_request_diff_id: merge_request_diff_id, relative_order: index, - sha: sha_attribute.serialize(sha), # rubocop:disable Cop/ActiveRecordSerialize + sha: Gitlab::Database::ShaAttribute.serialize(sha), # rubocop:disable Cop/ActiveRecordSerialize authored_date: Gitlab::Database.sanitize_timestamp(commit_hash[:authored_date]), committed_date: Gitlab::Database.sanitize_timestamp(commit_hash[:committed_date]) ) @@ -27,16 +26,4 @@ class MergeRequestDiffCommit < ApplicationRecord Gitlab::Database.bulk_insert(self.table_name, rows) end - - def to_hash - Gitlab::Git::Commit::SERIALIZE_KEYS.each_with_object({}) do |key, hash| - hash[key] = public_send(key) # rubocop:disable GitlabSecurity/PublicSend - end - end - - # We don't save these, because they would need a table or a serialised - # field. They aren't used anywhere, so just pretend the commit has no parents. - def parent_ids - [] - end end |