Adds a setting to limit the number of diff lines that should be displayed (default to 1500).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2112 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-12-07 15:21:40 +00:00
parent 02acc7fc28
commit fec86a9ce1
37 changed files with 203 additions and 1 deletions

View File

@@ -19,8 +19,11 @@ module Redmine
# Class used to parse unified diffs
class UnifiedDiff < Array
def initialize(diff, options={})
options.assert_valid_keys(:type, :max_lines)
diff_type = options[:type] || 'inline'
lines = 0
@truncated = false
diff_table = DiffTable.new(diff_type)
diff.each do |line|
if line =~ /^(---|\+\+\+) (.*)$/
@@ -28,10 +31,17 @@ module Redmine
diff_table = DiffTable.new(diff_type)
end
diff_table.add_line line
lines += 1
if options[:max_lines] && lines > options[:max_lines]
@truncated = true
break
end
end
self << diff_table unless diff_table.empty?
self
end
def truncated?; @truncated; end
end
# Class that represents a file diff