summaryrefslogtreecommitdiff
path: root/app/services/notes
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-21 15:38:33 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-23 16:27:30 -0500
commitab91f76e8b275d0fc1d78b38b95d4b2cd8e73bdb (patch)
treee22910b5a3fc8dee98c5d674ee030b46421a4727 /app/services/notes
parent52527be4387cb978402a330f2e4de96e586a62db (diff)
downloadgitlab-ce-ab91f76e8b275d0fc1d78b38b95d4b2cd8e73bdb.tar.gz
Add system note with link to diff comparison when MR discussion becomes outdated
Diffstat (limited to 'app/services/notes')
-rw-r--r--app/services/notes/diff_position_update_service.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/app/services/notes/diff_position_update_service.rb b/app/services/notes/diff_position_update_service.rb
index 0cb731f5bc3..eff7b287269 100644
--- a/app/services/notes/diff_position_update_service.rb
+++ b/app/services/notes/diff_position_update_service.rb
@@ -1,26 +1,29 @@
module Notes
class DiffPositionUpdateService < BaseService
def execute(note)
- new_position = tracer.trace(note.position)
+ results = tracer.trace(note.position)
+ return unless results
- # Don't update the position if the type doesn't match, since that means
- # the diff line commented on was changed, and the comment is now outdated
- old_position = note.position
- if new_position &&
- new_position != old_position &&
- new_position.type == old_position.type
+ position = results[:position]
+ outdated = results[:outdated]
- note.position = new_position
- end
+ if outdated
+ note.change_position = position
- note
+ if note.persisted? && current_user
+ SystemNoteService.diff_discussion_outdated(note.to_discussion, project, current_user, position)
+ end
+ else
+ note.position = position
+ note.change_position = nil
+ end
end
private
def tracer
@tracer ||= Gitlab::Diff::PositionTracer.new(
- repository: project.repository,
+ project: project,
old_diff_refs: params[:old_diff_refs],
new_diff_refs: params[:new_diff_refs],
paths: params[:paths]