summaryrefslogtreecommitdiff
path: root/app/controllers/projects/commit_controller.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-12-26 23:15:41 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-12-26 23:15:41 +0000
commit40c9bec847cd95dbbecc42a1148fea0af4edc567 (patch)
treef4b0fb15ca3db84971f9573aea6ce86e8986bad6 /app/controllers/projects/commit_controller.rb
parent1119c1f6569755751dcb6789b944df73a1c7be12 (diff)
downloadgitlab-ce-revert-79a816f3.tar.gz
Revert "Merge branch '23638-remove-builds-tab' into 'master'"revert-79a816f3
This reverts merge request !7763
Diffstat (limited to 'app/controllers/projects/commit_controller.rb')
-rw-r--r--app/controllers/projects/commit_controller.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 791ed88db30..8197d9e4c99 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -8,11 +8,13 @@ class Projects::CommitController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
- before_action :authorize_download_code!
+ before_action :authorize_download_code!, except: [:cancel_builds, :retry_builds]
+ before_action :authorize_update_build!, only: [:cancel_builds, :retry_builds]
before_action :authorize_read_pipeline!, only: [:pipelines]
+ before_action :authorize_read_commit_status!, only: [:builds]
before_action :commit
- before_action :define_commit_vars, only: [:show, :diff_for_path, :pipelines]
- before_action :define_status_vars, only: [:show, :pipelines]
+ before_action :define_commit_vars, only: [:show, :diff_for_path, :builds, :pipelines]
+ before_action :define_status_vars, only: [:show, :builds, :pipelines]
before_action :define_note_vars, only: [:show, :diff_for_path]
before_action :authorize_edit_tree!, only: [:revert, :cherry_pick]
@@ -33,6 +35,25 @@ class Projects::CommitController < Projects::ApplicationController
def pipelines
end
+ def builds
+ end
+
+ def cancel_builds
+ ci_builds.running_or_pending.each(&:cancel)
+
+ redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
+ end
+
+ def retry_builds
+ ci_builds.latest.failed.each do |build|
+ if build.retryable?
+ Ci::Build.retry(build, current_user)
+ end
+ end
+
+ redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
+ end
+
def branches
@branches = @project.repository.branch_names_contains(commit.id)
@tags = @project.repository.tag_names_contains(commit.id)
@@ -77,6 +98,10 @@ class Projects::CommitController < Projects::ApplicationController
@noteable = @commit ||= @project.commit(params[:id])
end
+ def ci_builds
+ @ci_builds ||= Ci::Build.where(pipeline: pipelines)
+ end
+
def define_commit_vars
return git_not_found! unless commit
@@ -108,6 +133,8 @@ class Projects::CommitController < Projects::ApplicationController
def define_status_vars
@ci_pipelines = project.pipelines.where(sha: commit.sha)
+ @statuses = CommitStatus.where(pipeline: @ci_pipelines).relevant
+ @builds = Ci::Build.where(pipeline: @ci_pipelines).relevant
end
def assign_change_commit_vars(mr_source_branch)