Commit ed69d26c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'a-bunch-of-import-improvements' into 'master'

A bunch of import improvements

See merge request gitlab-org/gitlab!21142
parents 4c7be6fe bc0c4318
......@@ -5,7 +5,7 @@ module DiffPositionableNote
included do
delegate :on_text?, :on_image?, to: :position, allow_nil: true
before_validation :set_original_position, on: :create
before_validation :update_position, on: :create, if: :on_text?
before_validation :update_position, on: :create, if: :on_text?, unless: :importing?
serialize :original_position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
serialize :position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
......
......@@ -21,8 +21,8 @@ class DiffNote < Note
validate :positions_complete
validate :verify_supported
before_validation :set_line_code, if: :on_text?
after_save :keep_around_commits
before_validation :set_line_code, if: :on_text?, unless: :importing?
after_save :keep_around_commits, unless: :importing?
after_commit :create_diff_file, on: :create
def discussion_class(*)
......
......@@ -242,7 +242,7 @@ class MergeRequest < ApplicationRecord
ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22'
after_save :keep_around_commit
after_save :keep_around_commit, unless: :importing?
alias_attribute :project, :target_project
alias_attribute :project_id, :target_project_id
......
......@@ -164,7 +164,7 @@ class MergeRequestDiff < ApplicationRecord
# hooks that run when an attribute was changed are run twice.
reset
keep_around_commits
keep_around_commits unless importing?
end
def set_as_latest_diff
......
......@@ -155,9 +155,9 @@ class Note < ApplicationRecord
after_initialize :ensure_discussion_id
before_validation :nullify_blank_type, :nullify_blank_line_code
before_validation :set_discussion_id, on: :create
after_save :keep_around_commit, if: :for_project_noteable?
after_save :expire_etag_cache
after_save :touch_noteable
after_save :keep_around_commit, if: :for_project_noteable?, unless: :importing?
after_save :expire_etag_cache, unless: :importing?
after_save :touch_noteable, unless: :importing?
after_destroy :expire_etag_cache
class << self
......
......@@ -56,6 +56,10 @@ class DraftNote < ApplicationRecord
commit_id.present?
end
def importing?
false
end
def resolvable?
false
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment