summaryrefslogtreecommitdiff
path: root/app/models/diff_note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/diff_note.rb')
-rw-r--r--app/models/diff_note.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index 70fbcb4c4e9..881ae5d1cad 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -12,7 +12,7 @@ class DiffNote < Note
validate :positions_complete
validate :verify_supported
- before_validation :set_original_position, on: :create
+ before_validation :set_original_position, :update_position, on: :create
before_validation :set_line_code
class << self
@@ -71,6 +71,26 @@ class DiffNote < Note
self.position.diff_refs == diff_refs
end
+ def update_position
+ return unless supported?
+ return if for_commit?
+
+ return if active?
+
+ Notes::DiffPositionUpdateService.new(
+ self.project,
+ nil,
+ old_diff_refs: self.position.diff_refs,
+ new_diff_refs: self.noteable.diff_refs,
+ paths: self.position.paths
+ ).execute(self)
+ end
+
+ def update_position!
+ update_position &&
+ Gitlab::Timeless.timeless(self, &:save)
+ end
+
private
def supported?