Fix ABC size of BlobController#show
This commit is contained in:
parent
4c45f8ba4b
commit
bbf2ef06eb
|
@ -37,33 +37,11 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
|
||||
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
|
||||
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
|
||||
|
||||
render 'show'
|
||||
show_html
|
||||
end
|
||||
|
||||
format.json do
|
||||
json = blob_json(@blob)
|
||||
return render_404 unless json
|
||||
|
||||
render json: json.merge(
|
||||
path: blob.path,
|
||||
name: blob.name,
|
||||
extension: blob.extension,
|
||||
size: blob.raw_size,
|
||||
mime_type: blob.mime_type,
|
||||
binary: blob.raw_binary?,
|
||||
simple_viewer: blob.simple_viewer&.class&.partial_name,
|
||||
rich_viewer: blob.rich_viewer&.class&.partial_name,
|
||||
show_viewer_switcher: !!blob.show_viewer_switcher?,
|
||||
render_error: blob.simple_viewer&.render_error || blob.rich_viewer&.render_error,
|
||||
raw_path: project_raw_path(project, @id),
|
||||
blame_path: project_blame_path(project, @id),
|
||||
commits_path: project_commits_path(project, @id),
|
||||
permalink: project_blob_path(project, File.join(@commit.id, @path))
|
||||
)
|
||||
show_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -207,4 +185,34 @@ class Projects::BlobController < Projects::ApplicationController
|
|||
@last_commit_sha = Gitlab::Git::Commit
|
||||
.last_for_path(@repository, @ref, @path).sha
|
||||
end
|
||||
|
||||
def show_html
|
||||
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
|
||||
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
|
||||
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
def show_json
|
||||
json = blob_json(@blob)
|
||||
return render_404 unless json
|
||||
|
||||
render json: json.merge(
|
||||
path: blob.path,
|
||||
name: blob.name,
|
||||
extension: blob.extension,
|
||||
size: blob.raw_size,
|
||||
mime_type: blob.mime_type,
|
||||
binary: blob.raw_binary?,
|
||||
simple_viewer: blob.simple_viewer&.class&.partial_name,
|
||||
rich_viewer: blob.rich_viewer&.class&.partial_name,
|
||||
show_viewer_switcher: !!blob.show_viewer_switcher?,
|
||||
render_error: blob.simple_viewer&.render_error || blob.rich_viewer&.render_error,
|
||||
raw_path: project_raw_path(project, @id),
|
||||
blame_path: project_blame_path(project, @id),
|
||||
commits_path: project_commits_path(project, @id),
|
||||
permalink: project_blob_path(project, File.join(@commit.id, @path))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue