summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-05-23 21:20:59 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-05-23 21:20:59 +0800
commit43981250c426595c9b3c03a5153ae05d3de2a8e2 (patch)
tree586f0656915e21d5c73239cfec7e5ac582856326 /app
parent876acc7e0d654ebc89df3c596cc504334a37f7d8 (diff)
downloadgitlab-ce-43981250c426595c9b3c03a5153ae05d3de2a8e2.tar.gz
Use controllers to redirect
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/build_artifacts_controller.rb49
-rw-r--r--app/controllers/projects/builds_controller.rb27
2 files changed, 76 insertions, 0 deletions
diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb
new file mode 100644
index 00000000000..873246f484e
--- /dev/null
+++ b/app/controllers/projects/build_artifacts_controller.rb
@@ -0,0 +1,49 @@
+class Projects::BuildArtifactsController < Projects::ApplicationController
+ include ExtractsPath
+ include RendersBlob
+
+ before_action :extract_ref_name_and_path
+
+ def download
+ redirect_to download_namespace_project_job_artifacts_path(project.namespace, project, job)
+ end
+
+ def browse
+ redirect_to browse_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
+ end
+
+ def file
+ redirect_to file_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
+ end
+
+ def raw
+ redirect_to raw_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
+ end
+
+ def latest_succeeded
+ redirect_to latest_succeeded_namespace_project_artifacts_path(project.namespace, project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
+ end
+
+ 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 job
+ @job ||= job_from_id || job_from_ref
+ end
+
+ def job_from_id
+ project.builds.find_by(id: params[:build_id]) if params[:build_id]
+ end
+
+ def job_from_ref
+ return unless @ref_name
+
+ jobs = project.latest_successful_builds_for(@ref_name)
+ jobs.find_by(name: params[:job])
+ end
+end
diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb
new file mode 100644
index 00000000000..013797a7313
--- /dev/null
+++ b/app/controllers/projects/builds_controller.rb
@@ -0,0 +1,27 @@
+class Projects::BuildsController < Projects::ApplicationController
+ def index
+ redirect_to namespace_project_jobs_path(project.namespace, project)
+ end
+
+ def show
+ redirect_to namespace_project_job_path(project.namespace, project, job)
+ end
+
+ def trace
+ redirect_to trace_namespace_project_job_path(project.namespace, project, job, format: params[:format])
+ end
+
+ def status
+ redirect_to status_namespace_project_job_path(project.namespace, project, job, format: params[:format])
+ end
+
+ def raw
+ redirect_to raw_namespace_project_job_path(project.namespace, project, job)
+ end
+
+ private
+
+ def job
+ @job ||= project.builds.find(params[:id])
+ end
+end