Improve diff performance by eliminating redundant checks for text blobs
On a merge request with over 1000 changed files, there were redundant calls to blob_text_viewable?, which incurred about 7% of the time. Improves #14775
This commit is contained in:
parent
6ad514d066
commit
48ff40a047
5 changed files with 27 additions and 6 deletions
|
@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
|
|||
|
||||
v 8.11.0 (unreleased)
|
||||
- Fix the title of the toggle dropdown button. !5515 (herminiotorres)
|
||||
- Improve diff performance by eliminating redundant checks for text blobs
|
||||
- Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
|
||||
- Fix CI status icon link underline (ClemMakesApps)
|
||||
- Cache the commit author in RequestStore to avoid extra lookups in PostReceive
|
||||
|
|
|
@ -13,7 +13,7 @@ module BlobHelper
|
|||
|
||||
blob = project.repository.blob_at(ref, path) rescue nil
|
||||
|
||||
return unless blob && blob_text_viewable?(blob)
|
||||
return unless blob
|
||||
|
||||
from_mr = options[:from_merge_request_id]
|
||||
link_opts = {}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
- if current_user
|
||||
.btn-group{ role: "group" }
|
||||
= edit_blob_link
|
||||
- if blob_text_viewable?(@blob)
|
||||
= edit_blob_link
|
||||
= replace_blob_link
|
||||
= delete_blob_link
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
= icon('comment')
|
||||
\
|
||||
|
||||
- if editable_diff?(diff_file)
|
||||
= edit_blob_link(@merge_request.source_project,
|
||||
@merge_request.source_branch, diff_file.new_path,
|
||||
from_merge_request_id: @merge_request.id)
|
||||
- if editable_diff?(diff_file)
|
||||
= edit_blob_link(@merge_request.source_project,
|
||||
@merge_request.source_branch, diff_file.new_path,
|
||||
from_merge_request_id: @merge_request.id,
|
||||
skip_visible_check: true)
|
||||
|
||||
= view_file_btn(diff_commit.id, diff_file, project)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe BlobHelper do
|
||||
include TreeHelper
|
||||
|
||||
let(:blob_name) { 'test.lisp' }
|
||||
let(:no_context_content) { ":type \"assem\"))" }
|
||||
let(:blob_content) { "(make-pathname :defaults name\n#{no_context_content}" }
|
||||
|
@ -65,4 +67,20 @@ describe BlobHelper do
|
|||
expect(sanitize_svg(blob).data).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#edit_blob_link" do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
before do
|
||||
allow(self).to receive(:current_user).and_return(double)
|
||||
end
|
||||
|
||||
it 'verifies blob is text' do
|
||||
expect(self).not_to receive(:blob_text_viewable?)
|
||||
|
||||
button = edit_blob_link(project, 'refs/heads/master', 'README.md')
|
||||
|
||||
expect(button).to start_with('<button')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue