]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup of RepositoriesController#annotate (#35432).
authorGo MAEDA <maeda@farend.jp>
Sat, 29 Apr 2023 06:59:40 +0000 (06:59 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 29 Apr 2023 06:59:40 +0000 (06:59 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22215 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/repositories_controller.rb

index 0e83bfa1ec297e46cb1832daaea8e4484ce39720..c143ed233ae86566f59ee47a6af25c471d94e263 100644 (file)
@@ -202,18 +202,12 @@ class RepositoriesController < ApplicationController
     (show_error_not_found; return) unless @entry
 
     @annotate = @repository.scm.annotate(@path, @rev)
-    if @annotate.nil? || @annotate.empty?
+    if @annotate.blank?
       @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
+    elsif @annotate.lines.sum(&:size) > Setting.file_max_size_displayed.to_i.kilobyte
+      @annotate = nil
+      @error_message = l(:error_scm_annotate_big_text_file)
     end
     @changeset = @repository.find_changeset_by_name(@rev)
   end