diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-12-07 15:21:40 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-12-07 15:21:40 +0000 |
commit | fec86a9ce100dec444872993c792fa99cc489b96 (patch) | |
tree | c0455d3f83558cdea85dd621a20c6f6910d4d7f0 /lib | |
parent | 02acc7fc28dc868757ccb48b224b8bee3429bff7 (diff) | |
download | redmine-fec86a9ce100dec444872993c792fa99cc489b96.tar.gz redmine-fec86a9ce100dec444872993c792fa99cc489b96.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/unified_diff.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/redmine/unified_diff.rb b/lib/redmine/unified_diff.rb index 5408a1ef9..bf4dec335 100644 --- a/lib/redmine/unified_diff.rb +++ b/lib/redmine/unified_diff.rb @@ -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 |