Commit 4ac0160a1184fe4acf86cd07040af78847577e11

Authored by randx
1 parent c7542eb8

Hande error with huge commits

app/controllers/commits_controller.rb
... ... @@ -41,6 +41,8 @@ class CommitsController < ApplicationController
41 41 if @commit.diffs.size > 200 && !params[:force_show_diff]
42 42 @suppress_diff = true
43 43 end
  44 + rescue Grit::Git::GitTimeout
  45 + render "huge_commit"
44 46 end
45 47  
46 48 def compare
... ...
app/views/commits/_commit_box.html.haml 0 → 100644
... ... @@ -0,0 +1,34 @@
  1 +.commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""}
  2 + .commit-head
  3 + = link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button"
  4 + %h3.commit-title
  5 + = commit_msg_with_link_to_issues(@project, @commit.title)
  6 + - if @commit.description.present?
  7 + %pre.commit-description
  8 + = commit_msg_with_link_to_issues(@project, @commit.description)
  9 + .commit-info
  10 + .row
  11 + .span4
  12 + = image_tag gravatar_icon(@commit.author_email, 40), :class => "avatar"
  13 + .author
  14 + %strong= @commit.author_name
  15 + authored
  16 + %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")}
  17 + #{time_ago_in_words(@commit.authored_date)} ago
  18 + - if @commit.different_committer?
  19 + .committer
  20 + →
  21 + %strong= @commit.committer_name
  22 + committed
  23 + %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")}
  24 + #{time_ago_in_words(@commit.committed_date)} ago
  25 + .span7.right
  26 + .sha-block
  27 + %span.cgray commit
  28 + %code= @commit.id
  29 + .sha-block
  30 + %span.cgray= pluralize(@commit.parents.count, "parent")
  31 + - @commit.parents.each do |parent|
  32 + = link_to parent.id[0...10], project_commit_path(@project, parent)
  33 +
  34 +
... ...
app/views/commits/huge_commit.html.haml 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 += render "commits/commit_box"
  2 +.alert-message.block-message.error
  3 + %h4 Commit diffs are too big to be displayed
... ...
app/views/commits/show.html.haml
1   -.commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""}
2   - .commit-head
3   - = link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button"
4   - %h3.commit-title
5   - = commit_msg_with_link_to_issues(@project, @commit.title)
6   - - if @commit.description.present?
7   - %pre.commit-description
8   - = commit_msg_with_link_to_issues(@project, @commit.description)
9   - .commit-info
10   - .row
11   - .span4
12   - = image_tag gravatar_icon(@commit.author_email, 40), :class => "avatar"
13   - .author
14   - %strong= @commit.author_name
15   - authored
16   - %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")}
17   - #{time_ago_in_words(@commit.authored_date)} ago
18   - - if @commit.different_committer?
19   - .committer
20   - →
21   - %strong= @commit.committer_name
22   - committed
23   - %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")}
24   - #{time_ago_in_words(@commit.committed_date)} ago
25   - .span7.right
26   - .sha-block
27   - %span.cgray commit
28   - %code= @commit.id
29   - .sha-block
30   - %span.cgray= pluralize(@commit.parents.count, "parent")
31   - - @commit.parents.each do |parent|
32   - = link_to parent.id[0...10], project_commit_path(@project, parent)
33   -
  1 += render "commits/commit_box"
34 2 = render "commits/diffs", :diffs => @commit.diffs
35 3 = render "notes/notes", :tid => @commit.id, :tt => "commit"
36 4 = render "notes/per_line_form"
... ...