summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-24 22:19:35 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-24 22:19:35 +0300
commite93f6b030a1a4c71aaea9a64672369723dc845a0 (patch)
tree9cc914807ef427d2b3358542714b7e03c75e170d /app/models/note.rb
parent69baa3afb21ed7426b393a2b723b776b3a38dc6f (diff)
downloadgitlab-ce-e93f6b030a1a4c71aaea9a64672369723dc845a0.tar.gz
Improve discussions
* check for outdated discussions by comparing diff * improve discussion UI Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 01026cd3994..590fd338fd9 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -179,10 +179,26 @@ class Note < ActiveRecord::Base
@diff ||= Gitlab::Git::Diff.new(st_diff) if st_diff.respond_to?(:map)
end
+ # Check if such line of code exists in merge request diff
+ # If exists - its active discussion
+ # If not - its outdated diff
def active?
- # TODO: determine if discussion is outdated
- # according to recent MR diff or not
- true
+ noteable.diffs.each do |mr_diff|
+ next unless mr_diff.new_path == self.diff.new_path
+
+ Gitlab::DiffParser.new(mr_diff.diff.lines.to_a, mr_diff.new_path).
+ each do |full_line, type, line_code, line_new, line_old|
+ if full_line == diff_line
+ return true
+ end
+ end
+ end
+
+ false
+ end
+
+ def outdated?
+ !active?
end
def diff_file_index