Extract ref_name and path in before_action, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_14469768
This commit is contained in:
parent
6a2d2bd18d
commit
b17df0507b
1 changed files with 10 additions and 5 deletions
|
@ -4,6 +4,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
|
||||||
layout 'project'
|
layout 'project'
|
||||||
before_action :authorize_read_build!
|
before_action :authorize_read_build!
|
||||||
before_action :authorize_update_build!, only: [:keep]
|
before_action :authorize_update_build!, only: [:keep]
|
||||||
|
before_action :extract_ref_name_and_path
|
||||||
before_action :validate_artifacts!
|
before_action :validate_artifacts!
|
||||||
|
|
||||||
def download
|
def download
|
||||||
|
@ -48,6 +49,12 @@ class Projects::ArtifactsController < Projects::ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def extract_ref_name_and_path
|
||||||
|
return unless params[:ref_name_and_path]
|
||||||
|
|
||||||
|
@ref_name, @path = extract_ref(params[:ref_name_and_path])
|
||||||
|
end
|
||||||
|
|
||||||
def validate_artifacts!
|
def validate_artifacts!
|
||||||
render_404 unless build && build.artifacts?
|
render_404 unless build && build.artifacts?
|
||||||
end
|
end
|
||||||
|
@ -61,12 +68,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_from_ref
|
def build_from_ref
|
||||||
if params[:ref_name_and_path]
|
return unless @ref_name
|
||||||
ref_name, @path = extract_ref(params[:ref_name_and_path])
|
|
||||||
builds = project.latest_successful_builds_for(ref_name)
|
|
||||||
|
|
||||||
builds.find_by(name: params[:job])
|
builds = project.latest_successful_builds_for(@ref_name)
|
||||||
end
|
builds.find_by(name: params[:job])
|
||||||
end
|
end
|
||||||
|
|
||||||
def artifacts_file
|
def artifacts_file
|
||||||
|
|
Loading…
Reference in a new issue