From 696f20391a73bbc017494d25aa258bcb34a545d7 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sun, 23 Apr 2023 15:39:58 +0900 Subject: [PATCH 1/2] Code cleanup of RepositoriesController#annotate --- app/controllers/repositories_controller.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0e83bfa1e..c143ed233 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 -- 2.39.1