summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-19 17:51:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-19 17:51:13 +0000
commitf162337e1b3625da7eedb747f1b2bb4752c27646 (patch)
treede961a92fadf7cdf1f5b56f41c77ac4411945775
parent93a33c62862d723722106fd7c624bb3e830085f6 (diff)
downloadredmine-f162337e1b3625da7eedb747f1b2bb4752c27646.tar.gz
redmine-f162337e1b3625da7eedb747f1b2bb4752c27646.zip
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
-rw-r--r--app/controllers/repositories_controller.rb2
-rw-r--r--app/views/repositories/changes.rhtml12
-rw-r--r--lang/bg.yml1
-rw-r--r--lang/cs.yml1
-rw-r--r--lang/da.yml1
-rw-r--r--lang/de.yml1
-rw-r--r--lang/en.yml3
-rw-r--r--lang/es.yml1
-rw-r--r--lang/fi.yml1
-rw-r--r--lang/fr.yml1
-rw-r--r--lang/he.yml1
-rw-r--r--lang/it.yml1
-rw-r--r--lang/ja.yml1
-rw-r--r--lang/ko.yml1
-rw-r--r--lang/lt.yml1
-rw-r--r--lang/nl.yml1
-rw-r--r--lang/pl.yml1
-rw-r--r--lang/pt-br.yml1
-rw-r--r--lang/pt.yml1
-rw-r--r--lang/ro.yml1
-rw-r--r--lang/ru.yml1
-rw-r--r--lang/sr.yml1
-rw-r--r--lang/sv.yml1
-rw-r--r--lang/uk.yml1
-rw-r--r--lang/zh-tw.yml1
-rw-r--r--lang/zh.yml1
-rw-r--r--lib/redmine/mime_type.rb2
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb14
-rw-r--r--test/functional/repositories_cvs_controller_test.rb2
-rw-r--r--test/functional/repositories_git_controller_test.rb7
-rw-r--r--test/functional/repositories_subversion_controller_test.rb2
31 files changed, 49 insertions, 18 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 349d0a505..10c235d65 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -110,7 +110,7 @@ class RepositoriesController < ApplicationController
def annotate
@annotate = @repository.scm.annotate(@path, @rev)
- show_error_not_found and return if @annotate.nil? || @annotate.empty?
+ render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty?
rescue Redmine::Scm::Adapters::CommandFailed => e
show_error_command_failed(e.message)
end
diff --git a/app/views/repositories/changes.rhtml b/app/views/repositories/changes.rhtml
index 55842a28b..2d7462b29 100644
--- a/app/views/repositories/changes.rhtml
+++ b/app/views/repositories/changes.rhtml
@@ -3,13 +3,11 @@
<h3><%=h @entry.name %></h3>
<p>
-<% if @entry.is_text? %>
- <% if @repository.supports_cat? %>
- <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
- <% end %>
- <% if @repository.supports_annotate? %>
- <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> |
- <% end %>
+<% if @repository.supports_cat? %>
+ <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
+<% end %>
+<% if @repository.supports_annotate? %>
+ <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> |
<% end %>
<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
diff --git a/lang/bg.yml b/lang/bg.yml
index 7b4e15720..70d5d7b20 100644
--- a/lang/bg.yml
+++ b/lang/bg.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/cs.yml b/lang/cs.yml
index 52ee9e451..28d52e3da 100644
--- a/lang/cs.yml
+++ b/lang/cs.yml
@@ -617,3 +617,4 @@ default_activity_development: Vývoj
enumeration_issue_priorities: Priority úkolů
enumeration_doc_categories: Kategorie dokumentů
enumeration_activities: Aktivity (sledování času)
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/da.yml b/lang/da.yml
index d80124520..8d70087b1 100644
--- a/lang/da.yml
+++ b/lang/da.yml
@@ -617,3 +617,4 @@ label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/de.yml b/lang/de.yml
index 36ae228b5..e9edbf8cc 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/en.yml b/lang/en.yml
index 2646e22a6..a37207e74 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -78,8 +78,9 @@ notice_account_pending: "Your account was created and is now pending administrat
notice_default_data_loaded: Default configuration successfully loaded.
error_can_t_load_default_data: "Default configuration could not be loaded: %s"
-error_scm_not_found: "Entry and/or revision doesn't exist in the repository."
+error_scm_not_found: "The entry or revision was not found in the repository."
error_scm_command_failed: "An error occurred when trying to access the repository: %s"
+error_scm_annotate: "The entry does not exist or can not be annotated."
error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
mail_subject_lost_password: Your %s password
diff --git a/lang/es.yml b/lang/es.yml
index 4a5eff1c9..8db240dfd 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -618,3 +618,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/fi.yml b/lang/fi.yml
index 5ff496985..9e8cfee2b 100644
--- a/lang/fi.yml
+++ b/lang/fi.yml
@@ -615,3 +615,4 @@ label_reverse_chronological_order: Käänteisessä aikajärjestyksessä
label_preferences: Asetukset
setting_default_projects_public: New projects are public by default
label_overall_activity: Overall activity
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/fr.yml b/lang/fr.yml
index 136f3b0b8..2ecafdcc5 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -80,6 +80,7 @@ notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s"
error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: %s"
+error_scm_annotate: "L'entrée n'existe pas ou ne peut pas être annotée."
error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas à ce projet"
mail_subject_lost_password: Votre mot de passe %s
diff --git a/lang/he.yml b/lang/he.yml
index 7450f04da..e4b0cb41f 100644
--- a/lang/he.yml
+++ b/lang/he.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/it.yml b/lang/it.yml
index 2a35740ac..5d6e5f365 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/ja.yml b/lang/ja.yml
index 1b5427be4..7e39db695 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/ko.yml b/lang/ko.yml
index f53274ec6..28db1d000 100644
--- a/lang/ko.yml
+++ b/lang/ko.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/lt.yml b/lang/lt.yml
index 957b8cc9c..97210ad1c 100644
--- a/lang/lt.yml
+++ b/lang/lt.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/nl.yml b/lang/nl.yml
index c197e05f9..2c92dd30c 100644
--- a/lang/nl.yml
+++ b/lang/nl.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/pl.yml b/lang/pl.yml
index 0ba187ff3..377f1438c 100644
--- a/lang/pl.yml
+++ b/lang/pl.yml
@@ -615,3 +615,4 @@ label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/pt-br.yml b/lang/pt-br.yml
index fbb82ea4a..898431ff3 100644
--- a/lang/pt-br.yml
+++ b/lang/pt-br.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/pt.yml b/lang/pt.yml
index d177a0775..99a60f350 100644
--- a/lang/pt.yml
+++ b/lang/pt.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/ro.yml b/lang/ro.yml
index d99b53a53..55e8ec372 100644
--- a/lang/ro.yml
+++ b/lang/ro.yml
@@ -615,3 +615,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/ru.yml b/lang/ru.yml
index 7b11b781f..4ba184828 100644
--- a/lang/ru.yml
+++ b/lang/ru.yml
@@ -619,3 +619,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/sr.yml b/lang/sr.yml
index 3584d823d..9eaacb4dd 100644
--- a/lang/sr.yml
+++ b/lang/sr.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/sv.yml b/lang/sv.yml
index ab16af51d..67a8c55e2 100644
--- a/lang/sv.yml
+++ b/lang/sv.yml
@@ -616,3 +616,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/uk.yml b/lang/uk.yml
index 7038640f2..be6b57d04 100644
--- a/lang/uk.yml
+++ b/lang/uk.yml
@@ -617,3 +617,4 @@ label_preferences: Preferences
setting_display_subprojects_issues: Display subprojects issues on main projects by default
label_overall_activity: Overall activity
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml
index 32bcd8419..3514f4c49 100644
--- a/lang/zh-tw.yml
+++ b/lang/zh-tw.yml
@@ -616,3 +616,4 @@ default_activity_development: 開發
enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤)
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lang/zh.yml b/lang/zh.yml
index e2d555fbf..48f6fc695 100644
--- a/lang/zh.yml
+++ b/lang/zh.yml
@@ -616,3 +616,4 @@ enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪)
setting_default_projects_public: New projects are public by default
+error_scm_annotate: "The entry does not exist or can not be annotated."
diff --git a/lib/redmine/mime_type.rb b/lib/redmine/mime_type.rb
index 57bdbcfe1..dfdfff407 100644
--- a/lib/redmine/mime_type.rb
+++ b/lib/redmine/mime_type.rb
@@ -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',
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 088f83af7..f1d076360 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -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
diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb
index 059823707..1e101f59a 100644
--- a/test/functional/repositories_cvs_controller_test.rb
+++ b/test/functional/repositories_cvs_controller_test.rb
@@ -83,7 +83,7 @@ class RepositoriesCvsControllerTest < Test::Unit::TestCase
def test_entry_not_found
get :entry, :id => 1, :path => ['sources', 'zzz.c']
assert_tag :tag => 'div', :attributes => { :class => /error/ },
- :content => /Entry and\/or revision doesn't exist/
+ :content => /The entry or revision was not found in the repository/
end
def test_entry_download
diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb
index fec0bbaa0..f8b3cb2bb 100644
--- a/test/functional/repositories_git_controller_test.rb
+++ b/test/functional/repositories_git_controller_test.rb
@@ -116,6 +116,13 @@ class RepositoriesGitControllerTest < Test::Unit::TestCase
:sibling => { :tag => 'td', :content => /jsmith/ },
:sibling => { :tag => 'td', :content => /watcher =/ }
end
+
+ def test_annotate_binary_file
+ get :annotate, :id => 3, :path => ['images', 'delete.png']
+ assert_response 500
+ assert_tag :tag => 'div', :attributes => { :class => /error/ },
+ :content => /can not be annotated/
+ end
else
puts "Git test repository NOT FOUND. Skipping functional tests !!!"
def test_fake; assert true end
diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb
index a70682818..9b21a13e8 100644
--- a/test/functional/repositories_subversion_controller_test.rb
+++ b/test/functional/repositories_subversion_controller_test.rb
@@ -72,7 +72,7 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
def test_entry_not_found
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
assert_tag :tag => 'div', :attributes => { :class => /error/ },
- :content => /Entry and\/or revision doesn't exist/
+ :content => /The entry or revision was not found in the repository/
end
def test_entry_download