Always show 'View' and 'Annotate' links on repository files (download will be forced when clicking 'View' if the file is binary).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1274 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-03-19 17:51:13 +00:00
parent 93a33c6286
commit f162337e1b
31 changed files with 49 additions and 18 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ module Redmine
'text/css' => 'css',
'text/html' => 'html,htm,xhtml',
'text/jsp' => 'jsp',
'text/x-c' => 'c,cpp,h',
'text/x-c' => 'c,cpp,cc,h,hh',
'text/x-java' => 'java',
'text/x-javascript' => 'js',
'text/x-html-template' => 'rhtml',
+8 -6
View File
@@ -231,13 +231,15 @@ module Redmine
identifier = 'HEAD' if identifier.blank?
cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}"
blame = Annotate.new
shellout(cmd) do |io|
io.each_line do |line|
next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)$/
blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip))
end
end
content = nil
shellout(cmd) { |io| io.binmode; content = io.read }
return nil if $? && $?.exitstatus != 0
# git annotates binary files
return nil if content.is_binary_data?
content.split("\n").each do |line|
next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)/
blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip))
end
blame
end