2014-07-15 11:28:21 -04:00
|
|
|
module DiffHelper
|
2014-09-08 09:27:12 -04:00
|
|
|
def safe_diff_files(project, diffs)
|
2014-07-15 11:28:21 -04:00
|
|
|
if diff_hard_limit_enabled?
|
|
|
|
diffs.first(Commit::DIFF_HARD_LIMIT_FILES)
|
|
|
|
else
|
|
|
|
diffs.first(Commit::DIFF_SAFE_FILES)
|
2014-09-08 09:27:12 -04:00
|
|
|
end.map do |diff|
|
|
|
|
Gitlab::Diff::File.new(project, @commit, diff)
|
2014-07-15 11:28:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-08 09:27:12 -04:00
|
|
|
def show_diff_size_warninig?(project, diffs)
|
|
|
|
safe_diff_files(project, diffs).size < diffs.size
|
2014-07-15 11:28:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def diff_hard_limit_enabled?
|
|
|
|
# Enabling hard limit allows user to see more diff information
|
|
|
|
if params[:force_show_diff].present?
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|