[refs #674] fixed undefined method 'binary?' for nil:NilClass when rename the file

This commit is contained in:
Alexander Machehin 2012-11-27 23:35:58 +06:00
parent 7be2df7578
commit 8ed71e0f03
3 changed files with 15 additions and 2 deletions

View File

@ -43,5 +43,6 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
params2 #FIXME git has other ref?
end
@commit = @project.repo.commit(ref) || raise(ActiveRecord::RecordNotFound)
@common_ancestor = @project.repo.commit(@project.repo.git.merge_base({}, @commit1, @commit)) || @commit1
end
end

View File

@ -6,5 +6,6 @@
- if commit_diff.b_path.present?
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path)
.clear
-unless (@project.repo.tree(commit_id) / commit_diff.b_path).binary?
-if commit_diff.diff.present? && !(@project.repo.tree(commit_id) / commit_diff.a_path).binary?
="a_path=#{commit_diff.a_path}; b_path=#{commit_diff.b_path}" if (@project.repo.tree(commit_id) / commit_diff.b_path).nil?
.diff_data=render_diff(commit_diff, :diff_counter => commit_diff_counter, :comments => @comments)

View File

@ -1,6 +1,17 @@
-begin
=render_diff_stats(@project.repo.diff_stats @commit1.id, @commit.id)
= "#{@commit1}...#{@commit}"
=render :partial => 'commit_diff', :collection => @project.repo.diff(@commit1.id, @commit.id)
=#render :partial => 'commit_diff', :collection => @project.repo.diff(@commit1.id, @commit.id)
-@project.repo.diff(@commit1.id, @commit.id).each_with_index do |commit_diff, diff_counter|
- commit_id = commit_diff.deleted_file ? @common_ancestor.id : @commit.id
.file
%a{:name => "diff-#{diff_counter}"}
.top
.l= h(commit_diff.a_path.rtruncate 120)
- if commit_diff.b_path.present?
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path)
.clear
-if commit_diff.diff.present? && !(@project.repo.tree(commit_id) / commit_diff.b_path).binary?
.diff_data=render_diff(commit_diff, :diff_counter => diff_counter)
- rescue Grit::Git::GitTimeout
%p= t 'layout.git.repositories.commit_diff_too_big'