diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /app/models/merge_request_diff_commit.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'app/models/merge_request_diff_commit.rb')
-rw-r--r-- | app/models/merge_request_diff_commit.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/app/models/merge_request_diff_commit.rb b/app/models/merge_request_diff_commit.rb index d9a1784cdda..66f1e45fd49 100644 --- a/app/models/merge_request_diff_commit.rb +++ b/app/models/merge_request_diff_commit.rb @@ -6,6 +6,12 @@ class MergeRequestDiffCommit < ApplicationRecord include BulkInsertSafe include ShaAttribute include CachedCommit + include IgnorableColumns + include FromUnion + + ignore_column %i[author_name author_email committer_name committer_email], + remove_with: '14.6', + remove_after: '2021-11-22' belongs_to :merge_request_diff @@ -51,9 +57,14 @@ class MergeRequestDiffCommit < ApplicationRecord committer = users[[commit_hash[:committer_name], commit_hash[:committer_email]]] + # These fields are only used to determine the author/committer IDs, we + # don't store them in the DB. + commit_hash = commit_hash + .except(:author_name, :author_email, :committer_name, :committer_email) + commit_hash.merge( - commit_author_id: author&.id, - committer_id: committer&.id, + commit_author_id: author.id, + committer_id: committer.id, merge_request_diff_id: merge_request_diff_id, relative_order: index, sha: Gitlab::Database::ShaAttribute.serialize(sha), # rubocop:disable Cop/ActiveRecordSerialize @@ -63,7 +74,7 @@ class MergeRequestDiffCommit < ApplicationRecord ) end - Gitlab::Database.main.bulk_insert(self.table_name, rows) # rubocop:disable Gitlab/BulkInsert + ApplicationRecord.legacy_bulk_insert(self.table_name, rows) # rubocop:disable Gitlab/BulkInsert end def self.prepare_commits_for_bulk_insert(commits) @@ -104,18 +115,18 @@ class MergeRequestDiffCommit < ApplicationRecord end def author_name - commit_author_id ? commit_author.name : super + commit_author&.name end def author_email - commit_author_id ? commit_author.email : super + commit_author&.email end def committer_name - committer_id ? committer.name : super + committer&.name end def committer_email - committer_id ? committer.email : super + committer&.email end end |