diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-24 09:16:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-24 09:16:22 +0300 |
commit | 6178536e7ea6b3d690899090cbaab41abdb31d2b (patch) | |
tree | 8ef6b0659eac6e1fd0ef9392cc07e499c4f6a03b /app/models/draft_note.rb | |
parent | ac1b601e581fc7f69784f2d771ba4382f6d5744e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/draft_note.rb')
-rw-r--r-- | app/models/draft_note.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/draft_note.rb b/app/models/draft_note.rb index febede9beba..9f7977fce68 100644 --- a/app/models/draft_note.rb +++ b/app/models/draft_note.rb @@ -25,6 +25,7 @@ class DraftNote < ApplicationRecord validates :merge_request_id, presence: true validates :author_id, presence: true, uniqueness: { scope: [:merge_request_id, :discussion_id] }, if: :discussion_id? validates :discussion_id, allow_nil: true, format: { with: /\A\h{40}\z/ } + validates :line_code, length: { maximum: 255 }, allow_nil: true scope :authored_by, ->(u) { where(author_id: u.id) } @@ -89,7 +90,11 @@ class DraftNote < ApplicationRecord end def line_code - @line_code ||= diff_file&.line_code_for_position(original_position) + super.presence || find_line_code + end + + def find_line_code + write_attribute(:line_code, diff_file&.line_code_for_position(original_position)) end def publish_params |