[refs #90] fixed git timeout error on the big diff
This commit is contained in:
parent
ba74024b29
commit
95e5804358
|
@ -10,11 +10,11 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@commit = @commentable = @project.repo.commit(params[:id]) || raise(ActiveRecord::RecordNotFound)
|
@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|
|
respond_to do |format|
|
||||||
format.html
|
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" }
|
format.patch { render :text => (@commit.to_patch rescue ''), :content_type => "text/plain" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -132,7 +132,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
@total_commits = @commits.count
|
@total_commits = @commits.count
|
||||||
@commits = @commits.last(100)
|
@commits = @commits.last(100)
|
||||||
|
|
||||||
@diff, @stats = @pull.diff, @pull.diff_stats
|
@stats = @pull.diff_stats
|
||||||
@comments, @commentable = @issue.comments, @issue
|
@comments, @commentable = @issue.comments, @issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,6 @@ module CommentsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment_anchor c
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -232,7 +232,7 @@ module DiffHelper
|
||||||
def render_line_comments
|
def render_line_comments
|
||||||
unless @in_wiki || @in_discussion
|
unless @in_wiki || @in_discussion
|
||||||
comments = @line_comments.select do |c|
|
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
|
end
|
||||||
tr_line_comments(comments) if comments.count > 0
|
tr_line_comments(comments) if comments.count > 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,10 +54,11 @@ class Comment < ActiveRecord::Base
|
||||||
User.find(subscribe.user).notifier.new_comment && User.find(subscribe.user).notifier.can_notify
|
User.find(subscribe.user).notifier.new_comment && User.find(subscribe.user).notifier.can_notify
|
||||||
end
|
end
|
||||||
|
|
||||||
def actual_inline_comment?(diff, force = false)
|
def actual_inline_comment?(diff = nil, force = false)
|
||||||
unless force
|
unless force
|
||||||
raise "This is not inline comment!" if data.blank? # for debug
|
raise "This is not inline comment!" if data.blank? # for debug
|
||||||
return data[:actual] unless data[:actual].nil?
|
return data[:actual] unless data[:actual].nil?
|
||||||
|
return false if diff.nil?
|
||||||
end
|
end
|
||||||
filepath, line_number = data[:path], data[:line]
|
filepath, line_number = data[:path], data[:line]
|
||||||
diff_path = (diff || commentable.diffs ).select {|d| d.a_path == data[:path]}
|
diff_path = (diff || commentable.diffs ).select {|d| d.a_path == data[:path]}
|
||||||
|
|
|
@ -13,6 +13,6 @@
|
||||||
|
|
||||||
-begin
|
-begin
|
||||||
= render_commit_stats(stats)
|
= render_commit_stats(stats)
|
||||||
= render :partial => 'commit_diff', :collection => @diff
|
= render :partial => 'commit_diff', :collection => @commit.diffs
|
||||||
- rescue Grit::Git::GitTimeout
|
- rescue Grit::Git::GitTimeout
|
||||||
%p= t 'layout.git.repositories.commit_diff_too_big'
|
%p= t 'layout.git.repositories.commit_diff_too_big'
|
||||||
|
|
|
@ -9,10 +9,12 @@
|
||||||
.both
|
.both
|
||||||
-begin
|
-begin
|
||||||
= render_diff_stats(@stats)
|
= render_diff_stats(@stats)
|
||||||
= render :partial => 'pull_diff', :collection => @diff
|
= render :partial => 'pull_diff', :collection => @pull.diff
|
||||||
- rescue Grit::Git::GitTimeout
|
- rescue => ex
|
||||||
|
-if ex.try(:message) == 'Grit::Git::GitTimeout'
|
||||||
%p= t 'layout.git.repositories.commit_diff_too_big'
|
%p= t 'layout.git.repositories.commit_diff_too_big'
|
||||||
|
-else
|
||||||
|
-raise ex
|
||||||
#commits.tab-pane
|
#commits.tab-pane
|
||||||
- if @total_commits > @commits.count
|
- if @total_commits > @commits.count
|
||||||
%div= t("projects.pull_requests.is_big", :count => @commits.count)
|
%div= t("projects.pull_requests.is_big", :count => @commits.count)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
.file
|
.file
|
||||||
.top
|
.top
|
||||||
.l=comment.data[:view_path]
|
.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"),
|
.r=link_to t("layout.pull_requests.view_full_changes"),
|
||||||
"#{project_commentable_path(@project, @commentable)}##{comment_anchor(comment)}",
|
"#{project_commentable_path(@project, @commentable)}##{comment_anchor(comment)}",
|
||||||
:class => 'link_to_full_changes'
|
:class => 'link_to_full_changes'
|
||||||
|
|
Loading…
Reference in New Issue