mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 21:05:49 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user