diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-03-22 14:57:56 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-03-22 14:57:56 +0300 |
commit | 78cee2c57b49d396c5998becfeb5032de196c939 (patch) | |
tree | 20f89a7a91159eee380f82e8069c5d1472818ff7 /app/controllers/projects/pipelines_settings_controller.rb | |
parent | 1ff339fad3e63a7ec2961de596e7b0fe4272fae9 (diff) |
Refactor AutoDevops pipeline logic into method
Diffstat (limited to 'app/controllers/projects/pipelines_settings_controller.rb')
-rw-r--r-- | app/controllers/projects/pipelines_settings_controller.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/controllers/projects/pipelines_settings_controller.rb b/app/controllers/projects/pipelines_settings_controller.rb index 6ccefb7e562..557671ab186 100644 --- a/app/controllers/projects/pipelines_settings_controller.rb +++ b/app/controllers/projects/pipelines_settings_controller.rb @@ -10,14 +10,7 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController if service.execute flash[:notice] = "Pipelines settings for '#{@project.name}' were successfully updated." - if service.run_auto_devops_pipeline? - if @project.empty_repo? - flash[:warning] = "This repository is currently empty. A new Auto DevOps pipeline will be created after a new file has been pushed to a branch." - else - CreatePipelineWorker.perform_async(project.id, current_user.id, project.default_branch, :web, ignore_skip_ci: true, save_on_errors: false) - flash[:success] = "A new Auto DevOps pipeline has been created, go to <a href=\"#{project_pipelines_path(@project)}\">Pipelines page</a> for details".html_safe - end - end + run_autodevops_pipeline(service) redirect_to project_settings_ci_cd_path(@project) else @@ -28,6 +21,18 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController private + def run_autodevops_pipeline(service) + return unless service.run_auto_devops_pipeline? + + if @project.empty_repo? + flash[:warning] = "This repository is currently empty. A new Auto DevOps pipeline will be created after a new file has been pushed to a branch." + return + end + + CreatePipelineWorker.perform_async(project.id, current_user.id, project.default_branch, :web, ignore_skip_ci: true, save_on_errors: false) + flash[:success] = "A new Auto DevOps pipeline has been created, go to <a href=\"#{project_pipelines_path(@project)}\">Pipelines page</a> for details".html_safe + end + def update_params params.require(:project).permit( :runners_token, :builds_enabled, :build_allow_git_fetch, |