]> source.dussan.org Git - redmine.git/commitdiff
Don't respond with the error template when annotate is not available.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jul 2016 09:22:42 +0000 (09:22 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jul 2016 09:22:42 +0000 (09:22 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15694 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/repositories_controller.rb
app/views/repositories/annotate.html.erb
test/functional/repositories_git_controller_test.rb

index 9bee5b8371c68c4eba06480a8c6d83a37391662e..07f1db0b488288cc8028f23e5aeff3ee1ea79bef 100644 (file)
@@ -211,14 +211,17 @@ class RepositoriesController < ApplicationController
 
     @annotate = @repository.scm.annotate(@path, @rev)
     if @annotate.nil? || @annotate.empty?
-      (render_error l(:error_scm_annotate); return)
-    end
-    ann_buf_size = 0
-    @annotate.lines.each do |buf|
-      ann_buf_size += buf.size
-    end
-    if ann_buf_size > Setting.file_max_size_displayed.to_i.kilobyte
-      (render_error l(:error_scm_annotate_big_text_file); return)
+      @annotate = nil
+      @error_message = l(:error_scm_annotate)
+    else
+      ann_buf_size = 0
+      @annotate.lines.each do |buf|
+        ann_buf_size += buf.size
+      end
+      if ann_buf_size > Setting.file_max_size_displayed.to_i.kilobyte
+        @annotate = nil
+        @error_message = l(:error_scm_annotate_big_text_file)
+      end
     end
     @changeset = @repository.find_changeset_by_name(@rev)
   end
index fcb6d3d8485f69b4f7b77e79497cca362ccc3a86..79a548f7e61ba474e70c04b8202da82fcadfc0ac 100644 (file)
@@ -8,8 +8,8 @@
 
 <%= render :partial => 'link_to_functions' %>
 
+<% if @annotate %>
 <% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %>
-
 <div class="autoscroll">
 <table class="filecontent annotate syntaxhl">
   <tbody>
@@ -38,6 +38,9 @@
   </tbody>
 </table>
 </div>
+<% else %>
+<p id="errorExplanation"><%= @error_message %></p>
+<% end %>
 
 <% html_title(l(:button_annotate)) -%>
 
index 4ec419c538b8f5faef31a137c53c9a470f2f67eb..4c2939e35f072c0ddf29c66d36f2de7cc859b0ec 100644 (file)
@@ -449,7 +449,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
       with_settings :default_language => 'en' do
         get :annotate, :id => PRJ_ID,
             :path => repository_path_hash(['images', 'edit.png'])[:param]
-        assert_response 500
+        assert_response 200
         assert_select 'p#errorExplanation', :text => /cannot be annotated/
       end
     end
@@ -459,7 +459,7 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
         get :annotate, :id => PRJ_ID,
             :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
             :rev => 'deff712f'
-        assert_response 500
+        assert_response 200
         assert_select 'p#errorExplanation', :text => /exceeds the maximum text file size/
 
         get :annotate, :id => PRJ_ID,