diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-29 11:00:29 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-29 11:00:29 +0400 |
commit | c51ac0484f37b65b31cd83b816b151fc7d50cf05 (patch) | |
tree | 1be6c9788fc16f65340bed60f97579c2f9a805ee /lib/gitlab | |
parent | 3083753c395722827385cf7542099cf6b4b60c4d (diff) | |
parent | d859d080942175082c1a0cf34d89c0eefd1a3c39 (diff) |
Merge pull request #5962 from skv-headless/editing-preview
editing preview
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/diff_parser.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/gitlab/diff_parser.rb b/lib/gitlab/diff_parser.rb index fb27280c4a4..14bbb328637 100644 --- a/lib/gitlab/diff_parser.rb +++ b/lib/gitlab/diff_parser.rb @@ -4,9 +4,9 @@ module Gitlab attr_reader :lines, :new_path - def initialize(diff) - @lines = diff.diff.lines.to_a - @new_path = diff.new_path + def initialize(lines, new_path = '') + @lines = lines + @new_path = new_path end def each @@ -18,10 +18,7 @@ module Gitlab lines_arr.each do |line| raw_line = line.dup - next if line.match(/^\-\-\- \/dev\/null/) - next if line.match(/^\+\+\+ \/dev\/null/) - next if line.match(/^\-\-\- a/) - next if line.match(/^\+\+\+ b/) + next if filename?(line) full_line = html_escape(line.gsub(/\n/, '')) full_line = ::Gitlab::InlineDiff.replace_markers full_line @@ -53,8 +50,17 @@ module Gitlab end end + def empty? + @lines.empty? + end + private + def filename?(line) + line.start_with?('--- /dev/null', '+++ /dev/null', '--- a', '+++ b', + '--- /tmp/diffy', '+++ /tmp/diffy') + end + def identification_type(line) if line[0] == "+" "new" |