##// END OF EJS Templates
Always show 'View' and 'Annotate' links on repository files (download will be forced when clicking 'View' if the file is binary)....
Jean-Philippe Lang -
r1259:f162337e1b36
parent child
Show More
@@ -110,7 +110,7 class RepositoriesController < ApplicationController
110
110
111 def annotate
111 def annotate
112 @annotate = @repository.scm.annotate(@path, @rev)
112 @annotate = @repository.scm.annotate(@path, @rev)
113 show_error_not_found and return if @annotate.nil? || @annotate.empty?
113 render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty?
114 rescue Redmine::Scm::Adapters::CommandFailed => e
114 rescue Redmine::Scm::Adapters::CommandFailed => e
115 show_error_command_failed(e.message)
115 show_error_command_failed(e.message)
116 end
116 end
@@ -3,13 +3,11
3 <h3><%=h @entry.name %></h3>
3 <h3><%=h @entry.name %></h3>
4
4
5 <p>
5 <p>
6 <% if @entry.is_text? %>
6 <% if @repository.supports_cat? %>
7 <% if @repository.supports_cat? %>
7 <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
8 <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
8 <% end %>
9 <% end %>
9 <% if @repository.supports_annotate? %>
10 <% if @repository.supports_annotate? %>
10 <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> |
11 <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> |
12 <% end %>
13 <% end %>
11 <% end %>
14 <%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
12 <%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
15 <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
13 <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -617,3 +617,4 default_activity_development: Vývoj
617 enumeration_issue_priorities: Priority úkolů
617 enumeration_issue_priorities: Priority úkolů
618 enumeration_doc_categories: Kategorie dokumentů
618 enumeration_doc_categories: Kategorie dokumentů
619 enumeration_activities: Aktivity (sledování času)
619 enumeration_activities: Aktivity (sledování času)
620 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -617,3 +617,4 label_reverse_chronological_order: In reverse chronological order
617 label_preferences: Preferences
617 label_preferences: Preferences
618 label_overall_activity: Overall activity
618 label_overall_activity: Overall activity
619 setting_default_projects_public: New projects are public by default
619 setting_default_projects_public: New projects are public by default
620 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -78,8 +78,9 notice_account_pending: "Your account was created and is now pending administrat
78 notice_default_data_loaded: Default configuration successfully loaded.
78 notice_default_data_loaded: Default configuration successfully loaded.
79
79
80 error_can_t_load_default_data: "Default configuration could not be loaded: %s"
80 error_can_t_load_default_data: "Default configuration could not be loaded: %s"
81 error_scm_not_found: "Entry and/or revision doesn't exist in the repository."
81 error_scm_not_found: "The entry or revision was not found in the repository."
82 error_scm_command_failed: "An error occurred when trying to access the repository: %s"
82 error_scm_command_failed: "An error occurred when trying to access the repository: %s"
83 error_scm_annotate: "The entry does not exist or can not be annotated."
83 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
84 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
84
85
85 mail_subject_lost_password: Your %s password
86 mail_subject_lost_password: Your %s password
@@ -618,3 +618,4 label_preferences: Preferences
618 setting_display_subprojects_issues: Display subprojects issues on main projects by default
618 setting_display_subprojects_issues: Display subprojects issues on main projects by default
619 label_overall_activity: Overall activity
619 label_overall_activity: Overall activity
620 setting_default_projects_public: New projects are public by default
620 setting_default_projects_public: New projects are public by default
621 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_reverse_chronological_order: Käänteisessä aikajärjestyksessä
615 label_preferences: Asetukset
615 label_preferences: Asetukset
616 setting_default_projects_public: New projects are public by default
616 setting_default_projects_public: New projects are public by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -80,6 +80,7 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
80 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s"
80 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s"
81 error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
81 error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
82 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: %s"
82 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: %s"
83 error_scm_annotate: "L'entrée n'existe pas ou ne peut pas être annotée."
83 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas à ce projet"
84 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas à ce projet"
84
85
85 mail_subject_lost_password: Votre mot de passe %s
86 mail_subject_lost_password: Votre mot de passe %s
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_reverse_chronological_order: In reverse chronological order
615 label_preferences: Preferences
615 label_preferences: Preferences
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -615,3 +615,4 label_preferences: Preferences
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
615 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 label_overall_activity: Overall activity
616 label_overall_activity: Overall activity
617 setting_default_projects_public: New projects are public by default
617 setting_default_projects_public: New projects are public by default
618 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -619,3 +619,4 label_preferences: Preferences
619 setting_display_subprojects_issues: Display subprojects issues on main projects by default
619 setting_display_subprojects_issues: Display subprojects issues on main projects by default
620 label_overall_activity: Overall activity
620 label_overall_activity: Overall activity
621 setting_default_projects_public: New projects are public by default
621 setting_default_projects_public: New projects are public by default
622 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 label_preferences: Preferences
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
616 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 label_overall_activity: Overall activity
617 label_overall_activity: Overall activity
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -617,3 +617,4 label_preferences: Preferences
617 setting_display_subprojects_issues: Display subprojects issues on main projects by default
617 setting_display_subprojects_issues: Display subprojects issues on main projects by default
618 label_overall_activity: Overall activity
618 label_overall_activity: Overall activity
619 setting_default_projects_public: New projects are public by default
619 setting_default_projects_public: New projects are public by default
620 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 default_activity_development: 開發
616 enumeration_issue_priorities: 項目優先權
616 enumeration_issue_priorities: 項目優先權
617 enumeration_doc_categories: 文件分類
617 enumeration_doc_categories: 文件分類
618 enumeration_activities: 活動 (時間追蹤)
618 enumeration_activities: 活動 (時間追蹤)
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -616,3 +616,4 enumeration_issue_priorities: 问题优先级
616 enumeration_doc_categories: 文档类别
616 enumeration_doc_categories: 文档类别
617 enumeration_activities: 活动(时间跟踪)
617 enumeration_activities: 活动(时间跟踪)
618 setting_default_projects_public: New projects are public by default
618 setting_default_projects_public: New projects are public by default
619 error_scm_annotate: "The entry does not exist or can not be annotated."
@@ -23,7 +23,7 module Redmine
23 'text/css' => 'css',
23 'text/css' => 'css',
24 'text/html' => 'html,htm,xhtml',
24 'text/html' => 'html,htm,xhtml',
25 'text/jsp' => 'jsp',
25 'text/jsp' => 'jsp',
26 'text/x-c' => 'c,cpp,h',
26 'text/x-c' => 'c,cpp,cc,h,hh',
27 'text/x-java' => 'java',
27 'text/x-java' => 'java',
28 'text/x-javascript' => 'js',
28 'text/x-javascript' => 'js',
29 'text/x-html-template' => 'rhtml',
29 'text/x-html-template' => 'rhtml',
@@ -231,13 +231,15 module Redmine
231 identifier = 'HEAD' if identifier.blank?
231 identifier = 'HEAD' if identifier.blank?
232 cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}"
232 cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}"
233 blame = Annotate.new
233 blame = Annotate.new
234 shellout(cmd) do |io|
234 content = nil
235 io.each_line do |line|
235 shellout(cmd) { |io| io.binmode; content = io.read }
236 next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)$/
237 blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip))
238 end
239 end
240 return nil if $? && $?.exitstatus != 0
236 return nil if $? && $?.exitstatus != 0
237 # git annotates binary files
238 return nil if content.is_binary_data?
239 content.split("\n").each do |line|
240 next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)/
241 blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip))
242 end
241 blame
243 blame
242 end
244 end
243
245
@@ -83,7 +83,7 class RepositoriesCvsControllerTest < Test::Unit::TestCase
83 def test_entry_not_found
83 def test_entry_not_found
84 get :entry, :id => 1, :path => ['sources', 'zzz.c']
84 get :entry, :id => 1, :path => ['sources', 'zzz.c']
85 assert_tag :tag => 'div', :attributes => { :class => /error/ },
85 assert_tag :tag => 'div', :attributes => { :class => /error/ },
86 :content => /Entry and\/or revision doesn't exist/
86 :content => /The entry or revision was not found in the repository/
87 end
87 end
88
88
89 def test_entry_download
89 def test_entry_download
@@ -116,6 +116,13 class RepositoriesGitControllerTest < Test::Unit::TestCase
116 :sibling => { :tag => 'td', :content => /jsmith/ },
116 :sibling => { :tag => 'td', :content => /jsmith/ },
117 :sibling => { :tag => 'td', :content => /watcher =/ }
117 :sibling => { :tag => 'td', :content => /watcher =/ }
118 end
118 end
119
120 def test_annotate_binary_file
121 get :annotate, :id => 3, :path => ['images', 'delete.png']
122 assert_response 500
123 assert_tag :tag => 'div', :attributes => { :class => /error/ },
124 :content => /can not be annotated/
125 end
119 else
126 else
120 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
127 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
121 def test_fake; assert true end
128 def test_fake; assert true end
@@ -72,7 +72,7 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
72 def test_entry_not_found
72 def test_entry_not_found
73 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
73 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
74 assert_tag :tag => 'div', :attributes => { :class => /error/ },
74 assert_tag :tag => 'div', :attributes => { :class => /error/ },
75 :content => /Entry and\/or revision doesn't exist/
75 :content => /The entry or revision was not found in the repository/
76 end
76 end
77
77
78 def test_entry_download
78 def test_entry_download
General Comments 0
You need to be logged in to leave comments. Login now