From 6347e9a60bd3c00a6a6616756ecc398079775fb2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 20 Mar 2013 10:19:00 +0200 Subject: [PATCH] Dont load diff in compare over 100 commits --- app/models/commit.rb | 9 ++++++++- app/views/compare/show.html.haml | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/commit.rb b/app/models/commit.rb index 17d41f27f..daba5414a 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -89,7 +89,14 @@ class Commit if first && last result[:same] = (first.id == last.id) result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)} - result[:diffs] = project.repo.diff(last.id, first.id) rescue [] + + # Dont load diff for 100+ commits + result[:diffs] = if result[:commits].size > 100 + [] + else + project.repo.diff(last.id, first.id) rescue [] + end + result[:commit] = Commit.new(first) end diff --git a/app/views/compare/show.html.haml b/app/views/compare/show.html.haml index d8ea3727d..476be2550 100644 --- a/app/views/compare/show.html.haml +++ b/app/views/compare/show.html.haml @@ -6,6 +6,12 @@ = render "form" +- if @commits.size > 100 + .alert.alert-block + %p + %strong Warning! This comparison include 100+ commits. + %p To prevent performance issue we dont show diff information. + - if @commits.present? %div.ui-box %h5.title -- 2.11.0