WIP lazy blobs
This commit is contained in:
parent
481644ca7c
commit
64c8ee47c9
5 changed files with 15 additions and 3 deletions
|
@ -33,6 +33,7 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
|
||||
def edit
|
||||
@last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha
|
||||
blob.load_all_data!(@repository)
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -51,6 +52,7 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
|
||||
def preview
|
||||
@content = params[:content]
|
||||
@blob.load_all_data!(@repository)
|
||||
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
|
||||
@diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/))
|
||||
|
||||
|
@ -65,6 +67,7 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
def diff
|
||||
@blob.load_all_data!(@repository)
|
||||
@form = UnfoldForm.new(params)
|
||||
@lines = @blob.data.lines[@form.since - 1..@form.to - 1]
|
||||
|
||||
|
|
|
@ -205,7 +205,11 @@ module Ci
|
|||
end
|
||||
|
||||
def ci_yaml_file
|
||||
@ci_yaml_file ||= project.repository.blob_at(sha, '.gitlab-ci.yml').data
|
||||
return @ci_yaml_file if defined?(@ci_yaml_file)
|
||||
|
||||
blob = project.repository.blob_at(sha, '.gitlab-ci.yml')
|
||||
blob.load_all_data!(project.repository)
|
||||
@ci_yaml_file = blob.data
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -31,6 +31,8 @@ class Tree
|
|||
|
||||
git_repo = repository.raw_repository
|
||||
@readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path)
|
||||
@readme.load_all_data!(git_repo)
|
||||
@readme
|
||||
end
|
||||
|
||||
def trees
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
- if blob.lfs_pointer?
|
||||
= render "download", blob: blob
|
||||
- elsif blob.text?
|
||||
- blob.load_all_data!(@repository)
|
||||
= render "text", blob: blob
|
||||
- elsif blob.image?
|
||||
= render "image", blob: blob
|
||||
|
|
|
@ -58,9 +58,11 @@ module API
|
|||
commit = user_project.commit(ref)
|
||||
not_found! 'Commit' unless commit
|
||||
|
||||
blob = user_project.repository.blob_at(commit.sha, file_path)
|
||||
repo = user_project.repository
|
||||
blob = repo.blob_at(commit.sha, file_path)
|
||||
|
||||
if blob
|
||||
blob.load_all_data!(repo)
|
||||
status(200)
|
||||
|
||||
{
|
||||
|
@ -72,7 +74,7 @@ module API
|
|||
ref: ref,
|
||||
blob_id: blob.id,
|
||||
commit_id: commit.id,
|
||||
last_commit_id: user_project.repository.last_commit_for_path(commit.sha, file_path).id
|
||||
last_commit_id: repo.last_commit_for_path(commit.sha, file_path).id
|
||||
}
|
||||
else
|
||||
not_found! 'File'
|
||||
|
|
Loading…
Reference in a new issue