]> source.dussan.org Git - redmine.git/commitdiff
Always show 'View' and 'Annotate' links on repository files (download will be forced...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 19 Mar 2008 17:51:13 +0000 (17:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 19 Mar 2008 17:51:13 +0000 (17:51 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1274 e93f8b46-1217-0410-a6f0-8f06a7374b81

31 files changed:
app/controllers/repositories_controller.rb
app/views/repositories/changes.rhtml
lang/bg.yml
lang/cs.yml
lang/da.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fi.yml
lang/fr.yml
lang/he.yml
lang/it.yml
lang/ja.yml
lang/ko.yml
lang/lt.yml
lang/nl.yml
lang/pl.yml
lang/pt-br.yml
lang/pt.yml
lang/ro.yml
lang/ru.yml
lang/sr.yml
lang/sv.yml
lang/uk.yml
lang/zh-tw.yml
lang/zh.yml
lib/redmine/mime_type.rb
lib/redmine/scm/adapters/git_adapter.rb
test/functional/repositories_cvs_controller_test.rb
test/functional/repositories_git_controller_test.rb
test/functional/repositories_subversion_controller_test.rb

index 349d0a505eaf4241e0c6dd41784905668eb5d6c4..10c235d6535bf48bb8bc535e2e92b32ce6ca4f06 100644 (file)
@@ -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
index 55842a28b9d8068a8bb0c0dd8aba42577790dffd..2d7462b297f076eb8b82b2929df9ae8461109d79 100644 (file)
@@ -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 %>
index 7b4e15720d16bf7936f08a950fee9c40a17e04cd..70d5d7b20497aadeaac7b5a88fbf0c53528fe77d 100644 (file)
@@ -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."
index 52ee9e451f8ed4fef0ffd40fde7ceb5f8fa3ace7..28d52e3da90f605ca89c93a4980c1a19602c4e50 100644 (file)
@@ -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."
index d8012452035e54bf3df667928d94fe1c017d5652..8d70087b16a34fc198c348bcdc5c397522e38b4a 100644 (file)
@@ -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."
index 36ae228b5a2df39ffcdf3116116a7ff404a4ba92..e9edbf8cc3cc3cdcf84c50ae4055009bab80ea02 100644 (file)
@@ -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."
index 2646e22a6511b58bdc4c0b62a368cfa6212d93b4..a37207e7448c509685b9f9b9e6eb6b6c017a1862 100644 (file)
@@ -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
index 4a5eff1c990ecca79693a4a8b3345bbbc45467b4..8db240dfda00ba634c21e4a322057b0dcf802ab3 100644 (file)
@@ -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."
index 5ff4969855a0d04dfd427f2af81ccc01a15e0d33..9e8cfee2b28adb0be5c24e59b4fed4e2f140ef0b 100644 (file)
@@ -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."
index 136f3b0b87c2757d2f8ae1e9997a94d8d391215f..2ecafdcc599976567b76a70c57c730b936f9121f 100644 (file)
@@ -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
index 7450f04da6501f49d5f737e4d1b4a4189053e016..e4b0cb41f090c8c7fdaf8e80f6825d5d8bddfb32 100644 (file)
@@ -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."
index 2a35740ac4eaba1a4e0308c63bc857ac97f64ffc..5d6e5f36503d42e6dddd9b39be229e8c0334deba 100644 (file)
@@ -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."
index 1b5427be44e610820dbac204003d26cc8b5cfac6..7e39db6955f3ab11e98dd9c0edc0720bf114c976 100644 (file)
@@ -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."
index f53274ec6a488aed5e8048c94a699f8a7c5fe97b..28db1d0003121fe8c5a17b5d7703f61afd922803 100644 (file)
@@ -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."
index 957b8cc9c540df8d00fb92608067eff6e0b6a908..97210ad1c465e4f363295d558d777e6796db0867 100644 (file)
@@ -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."
index c197e05f92e00a007cf6ee340ada1388e5b065b1..2c92dd30cfe910ce0d74824f7524a3b3282d2e73 100644 (file)
@@ -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."
index 0ba187ff332a21288c0c3b2e95c448e8a2437aaf..377f1438cecc05da15dc1d8588bc91dc32ee2152 100644 (file)
@@ -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."
index fbb82ea4ad0ead6bdb73170966dd805c879a04ad..898431ff3472196f922ef03bdb72415ddb60dc26 100644 (file)
@@ -615,3 +615,4 @@ label_preferences: Preferences
 setting_display_subprojects_issues: Display subprojects issues on main projects by default\r
 label_overall_activity: Overall activity\r
 setting_default_projects_public: New projects are public by default\r
+error_scm_annotate: "The entry does not exist or can not be annotated."\r
index d177a0775994019bfe1ca12781a10a2fa72ef6e1..99a60f3506ce8cdd07edea9f217b797b843821b1 100644 (file)
@@ -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."
index d99b53a53db0a453097d3b973681b0e372ab37ed..55e8ec3725428df682fff3d5a3b5332da7e9f4f0 100644 (file)
@@ -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."
index 7b11b781f41c156a7de77f79501cb5bb3c68d915..4ba184828fa825ad7d72543f536d7735c16f8231 100644 (file)
@@ -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."
index 3584d823d9d74734ce9894e9ad8796a62f4ec335..9eaacb4dd80f36d372b0b5caa64a97935d97a012 100644 (file)
@@ -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."
index ab16af51ddc97707d1d1ac66f4d6084ac4ab9acc..67a8c55e2ff03b888792e7d6ba4cd6ef82a59c49 100644 (file)
@@ -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."
index 7038640f2855d75b1e5fd4e1b349b3ce0e0544c1..be6b57d04a4009093779a2991debb9125e82a448 100644 (file)
@@ -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."
index 32bcd8419fbbfd111a3c49c2fa7015571f7cba0e..3514f4c49bbb64e1721941f5bcfd14f399df27dc 100644 (file)
@@ -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."
index e2d555fbfe9e8307a62735a08a2db44932ebcfb2..48f6fc6954549a5a894919a59319648eed7f82f4 100644 (file)
@@ -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."
index 57bdbcfe1c95c4eb435c084b8c527e933d7bd09a..dfdfff407516721ce3581c3413a7ad5cb816474e 100644 (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',
index 088f83af7801164c680a923ee2904419bdfe987b..f1d076360fed39671ba8fa850e25ed4534cfe5b9 100644 (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
         
index 0598237077a718ec88706058545dfae608336b90..1e101f59abf724a19e076c3e1ea05aefae92f7c7 100644 (file)
@@ -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
index fec0bbaa09f8c333f806e8ba75aace1258f68ca2..f8b3cb2bb45d3b262221b098bb5eed90a2911092 100644 (file)
@@ -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
index a706828184e0362a43ac037a008d06b2bde9485c..9b21a13e8cb584b8db39931f4eacf97a281faa50 100644 (file)
@@ -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