Commit 6347e9a60bd3c00a6a6616756ecc398079775fb2

Authored by Dmitriy Zaporozhets
1 parent 72db22d3

Dont load diff in compare over 100 commits

app/models/commit.rb
... ... @@ -89,7 +89,14 @@ class Commit
89 89 if first && last
90 90 result[:same] = (first.id == last.id)
91 91 result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)}
92   - result[:diffs] = project.repo.diff(last.id, first.id) rescue []
  92 +
  93 + # Dont load diff for 100+ commits
  94 + result[:diffs] = if result[:commits].size > 100
  95 + []
  96 + else
  97 + project.repo.diff(last.id, first.id) rescue []
  98 + end
  99 +
93 100 result[:commit] = Commit.new(first)
94 101 end
95 102  
... ...
app/views/compare/show.html.haml
... ... @@ -6,6 +6,12 @@
6 6  
7 7 = render "form"
8 8  
  9 +- if @commits.size > 100
  10 + .alert.alert-block
  11 + %p
  12 + %strong Warning! This comparison include 100+ commits.
  13 + %p To prevent performance issue we dont show diff information.
  14 +
9 15 - if @commits.present?
10 16 %div.ui-box
11 17 %h5.title
... ...