diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-11 18:17:32 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-11 18:17:32 +0800 |
commit | f601ec54fcfad7f365d3488c0a48575862c48958 (patch) | |
tree | 82802e72a5ee827b34be0b1a4355366adea3dde0 /app/controllers/projects/artifacts_controller.rb | |
parent | 8f469c33cc8b90e1bcae8ddd5599ce2a2957a3af (diff) | |
download | gitlab-ce-f601ec54fcfad7f365d3488c0a48575862c48958.tar.gz |
Introduce Projects::ArtifactsController#search:
So we redirect from ref and build_name to the particular build, namely:
* /u/r/artifacts/ref/build_name/* -> /u/r/builds/:build_id/artifacts/*
For:
* download
* browse
* file
Diffstat (limited to 'app/controllers/projects/artifacts_controller.rb')
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index f11c8321464..c00295cd3b5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -35,14 +35,34 @@ class Projects::ArtifactsController < Projects::ApplicationController redirect_to namespace_project_build_path(project.namespace, project, build) end + def search + url = namespace_project_build_url(project.namespace, project, build) + + if params[:path] + redirect_to "#{url}/artifacts/#{params[:path]}" + else + render_404 + end + end + private def validate_artifacts! - render_404 unless build.artifacts? + render_404 unless build && build.artifacts? end def build - @build ||= project.builds.find_by!(id: params[:build_id]) + @build ||= build_from_id || build_from_ref + end + + def build_from_id + project.builds.find_by(id: params[:build_id]) if params[:build_id] + end + + def build_from_ref + if params[:ref] + project.builds_for(params[:build_name], params[:ref]).latest.first + end end def artifacts_file |