summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-12 13:19:35 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-12 13:19:35 +0200
commit940ed58e768af5580f65159c4040541f29663d4a (patch)
tree0331605d7b5ac22be0c971e1f64452703bdeacce /app/models/note.rb
parentc58edd7c708c39a6e7c60bd96c7f97ced370f304 (diff)
parent430758653ce7e4d32b40648e6263b79c2709bdad (diff)
downloadgitlab-ce-940ed58e768af5580f65159c4040541f29663d4a.tar.gz
Merge branch 'commit-comments' of https://gitlab.com/jeroenj/gitlab-ce into jeroenj/gitlab-ce-commit-comments
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: CHANGELOG
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index df45d023a00..5bf645bbd1d 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -317,7 +317,7 @@ class Note < ActiveRecord::Base
end
def diff_file_index
- line_code.split('_')[0]
+ line_code.split('_')[0] if line_code
end
def diff_file_name
@@ -333,11 +333,11 @@ class Note < ActiveRecord::Base
end
def diff_old_line
- line_code.split('_')[1].to_i
+ line_code.split('_')[1].to_i if line_code
end
def diff_new_line
- line_code.split('_')[2].to_i
+ line_code.split('_')[2].to_i if line_code
end
def generate_line_code(line)
@@ -358,6 +358,20 @@ class Note < ActiveRecord::Base
@diff_line
end
+ def diff_line_type
+ return @diff_line_type if @diff_line_type
+
+ if diff
+ diff_lines.each do |line|
+ if generate_line_code(line) == self.line_code
+ @diff_line_type = line.type
+ end
+ end
+ end
+
+ @diff_line_type
+ end
+
def truncated_diff_lines
max_number_of_lines = 16
prev_match_line = nil