Blob#load_all_data! doesn’t need an argument
This commit is contained in:
parent
fc1090d9f3
commit
dbffaaa97e
10 changed files with 15 additions and 13 deletions
|
@ -55,7 +55,7 @@ class Projects::BlobController < Projects::ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if can_collaborate_with_project?
|
if can_collaborate_with_project?
|
||||||
blob.load_all_data!(@repository)
|
blob.load_all_data!
|
||||||
else
|
else
|
||||||
redirect_to action: 'show'
|
redirect_to action: 'show'
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ class Projects::BlobController < Projects::ApplicationController
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
@content = params[:content]
|
@content = params[:content]
|
||||||
@blob.load_all_data!(@repository)
|
@blob.load_all_data!
|
||||||
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
|
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
|
||||||
diff_lines = diffy.diff.scan(/.*\n/)[2..-1]
|
diff_lines = diffy.diff.scan(/.*\n/)[2..-1]
|
||||||
diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines)
|
diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines)
|
||||||
|
@ -111,7 +111,7 @@ class Projects::BlobController < Projects::ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def blob
|
def blob
|
||||||
@blob ||= Blob.decorate(@repository.blob_at(@commit.id, @path), @project)
|
@blob ||= @repository.blob_at(@commit.id, @path)
|
||||||
|
|
||||||
if @blob
|
if @blob
|
||||||
@blob
|
@blob
|
||||||
|
|
|
@ -94,6 +94,10 @@ class Blob < SimpleDelegator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_all_data!
|
||||||
|
super(project.repository) if project
|
||||||
|
end
|
||||||
|
|
||||||
def no_highlighting?
|
def no_highlighting?
|
||||||
raw_size && raw_size > MAXIMUM_TEXT_HIGHLIGHT_SIZE
|
raw_size && raw_size > MAXIMUM_TEXT_HIGHLIGHT_SIZE
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,7 @@ module BlobViewer
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare!
|
def prepare!
|
||||||
if blob.project
|
blob.load_all_data!
|
||||||
blob.load_all_data!(blob.project.repository)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_error
|
def render_error
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ class Repository
|
||||||
blob = blob_at(sha, path)
|
blob = blob_at(sha, path)
|
||||||
return unless blob
|
return unless blob
|
||||||
|
|
||||||
blob.load_all_data!(self)
|
blob.load_all_data!
|
||||||
blob.data
|
blob.data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- blob = diff_file.blob
|
- blob = diff_file.blob
|
||||||
- blob.load_all_data!(diff_file.repository)
|
- blob.load_all_data!
|
||||||
- total_lines = blob.lines.size
|
- total_lines = blob.lines.size
|
||||||
- total_lines -= 1 if total_lines > 0 && blob.lines.last.blank?
|
- total_lines -= 1 if total_lines > 0 && blob.lines.last.blank?
|
||||||
- if diff_view == :parallel
|
- if diff_view == :parallel
|
||||||
|
|
|
@ -25,7 +25,7 @@ module API
|
||||||
@blob = @repo.blob_at(@commit.sha, params[:file_path])
|
@blob = @repo.blob_at(@commit.sha, params[:file_path])
|
||||||
|
|
||||||
not_found!('File') unless @blob
|
not_found!('File') unless @blob
|
||||||
@blob.load_all_data!(@repo)
|
@blob.load_all_data!
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit_response(attrs)
|
def commit_response(attrs)
|
||||||
|
|
|
@ -56,7 +56,7 @@ module API
|
||||||
blob = repo.blob_at(commit.sha, params[:file_path])
|
blob = repo.blob_at(commit.sha, params[:file_path])
|
||||||
not_found!('File') unless blob
|
not_found!('File') unless blob
|
||||||
|
|
||||||
blob.load_all_data!(repo)
|
blob.load_all_data!
|
||||||
status(200)
|
status(200)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def highlighted_lines
|
def highlighted_lines
|
||||||
@blob.load_all_data!(repository)
|
@blob.load_all_data!
|
||||||
@highlighted_lines ||=
|
@highlighted_lines ||=
|
||||||
Gitlab::Highlight.highlight(@blob.path, @blob.data, repository: repository).lines
|
Gitlab::Highlight.highlight(@blob.path, @blob.data, repository: repository).lines
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Gitlab
|
||||||
blob = repository.blob_at(ref, file_name)
|
blob = repository.blob_at(ref, file_name)
|
||||||
return [] unless blob
|
return [] unless blob
|
||||||
|
|
||||||
blob.load_all_data!(repository)
|
blob.load_all_data!
|
||||||
highlight(file_name, blob.data, repository: repository).lines.map!(&:html_safe)
|
highlight(file_name, blob.data, repository: repository).lines.map!(&:html_safe)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -648,7 +648,7 @@ describe 'Git HTTP requests', lib: true do
|
||||||
# Provide a dummy file in its place
|
# Provide a dummy file in its place
|
||||||
allow_any_instance_of(Repository).to receive(:blob_at).and_call_original
|
allow_any_instance_of(Repository).to receive(:blob_at).and_call_original
|
||||||
allow_any_instance_of(Repository).to receive(:blob_at).with('b83d6e391c22777fca1ed3012fce84f633d7fed0', 'info/refs') do
|
allow_any_instance_of(Repository).to receive(:blob_at).with('b83d6e391c22777fca1ed3012fce84f633d7fed0', 'info/refs') do
|
||||||
Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt')
|
Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project)
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/#{project.path_with_namespace}/blob/master/info/refs"
|
get "/#{project.path_with_namespace}/blob/master/info/refs"
|
||||||
|
|
Loading…
Reference in a new issue