[refs #90] fixed git timeout error on the big diff

This commit is contained in:
Alexander Machehin 2012-10-26 20:03:46 +06:00
parent ba74024b29
commit 95e5804358
9 changed files with 18 additions and 15 deletions

View File

@ -10,11 +10,11 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
def show
@commit = @commentable = @project.repo.commit(params[:id]) || raise(ActiveRecord::RecordNotFound)
@comments, @diff = Comment.for_commit(@commit), @commit.diffs
@comments = Comment.for_commit(@commit)
respond_to do |format|
format.html
format.diff { render :text => (@diff.map(&:diff).join("\n") rescue ''), :content_type => "text/plain" }
format.diff { render :text => (@commit.diffs.map(&:diff).join("\n") rescue ''), :content_type => "text/plain" }
format.patch { render :text => (@commit.to_patch rescue ''), :content_type => "text/plain" }
end
end

View File

@ -132,7 +132,7 @@ class Projects::PullRequestsController < Projects::BaseController
@total_commits = @commits.count
@commits = @commits.last(100)
@diff, @stats = @pull.diff, @pull.diff_stats
@stats = @pull.diff_stats
@comments, @commentable = @issue.comments, @issue
end

View File

@ -25,6 +25,6 @@ module CommentsHelper
end
def comment_anchor c
"#{(c.data.present? && c.actual_inline_comment?(@diff)) ? 'diff-' : ''}comment#{c.id}"
"#{(c.data.present? && c.actual_inline_comment?) ? 'diff-' : ''}comment#{c.id}"
end
end

View File

@ -232,7 +232,7 @@ module DiffHelper
def render_line_comments
unless @in_wiki || @in_discussion
comments = @line_comments.select do |c|
c.data.try('[]', :line) == @num_line.to_s && c.actual_inline_comment?(@diff)
c.data.try('[]', :line) == @num_line.to_s && c.actual_inline_comment?
end
tr_line_comments(comments) if comments.count > 0
end

View File

@ -54,10 +54,11 @@ class Comment < ActiveRecord::Base
User.find(subscribe.user).notifier.new_comment && User.find(subscribe.user).notifier.can_notify
end
def actual_inline_comment?(diff, force = false)
def actual_inline_comment?(diff = nil, force = false)
unless force
raise "This is not inline comment!" if data.blank? # for debug
return data[:actual] unless data[:actual].nil?
return false if diff.nil?
end
filepath, line_number = data[:path], data[:line]
diff_path = (diff || commentable.diffs ).select {|d| d.a_path == data[:path]}

View File

@ -13,6 +13,6 @@
-begin
= render_commit_stats(stats)
= render :partial => 'commit_diff', :collection => @diff
= render :partial => 'commit_diff', :collection => @commit.diffs
- rescue Grit::Git::GitTimeout
%p= t 'layout.git.repositories.commit_diff_too_big'

View File

@ -9,10 +9,12 @@
.both
-begin
= render_diff_stats(@stats)
= render :partial => 'pull_diff', :collection => @diff
- rescue Grit::Git::GitTimeout
= render :partial => 'pull_diff', :collection => @pull.diff
- rescue => ex
-if ex.try(:message) == 'Grit::Git::GitTimeout'
%p= t 'layout.git.repositories.commit_diff_too_big'
-else
-raise ex
#commits.tab-pane
- if @total_commits > @commits.count
%div= t("projects.pull_requests.is_big", :count => @commits.count)

View File

@ -2,7 +2,7 @@
.file
.top
.l=comment.data[:view_path]
-if comment.actual_inline_comment? @diff
-if comment.actual_inline_comment? @pull.diff
.r=link_to t("layout.pull_requests.view_full_changes"),
"#{project_commentable_path(@project, @commentable)}##{comment_anchor(comment)}",
:class => 'link_to_full_changes'