diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-07-03 10:17:07 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-07-04 09:35:25 +0100 |
commit | 99dea5fa13286346f8c7066d803eb04f4e989663 (patch) | |
tree | 53f87b3caca11b825dee9de433815f2fd69174b0 /app | |
parent | 55e2df6c804202a39d0165289988062a693087aa (diff) | |
download | gitlab-ce-99dea5fa13286346f8c7066d803eb04f4e989663.tar.gz |
Makes production environment the default environment for a project
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 1a586105a6d..27b7425b965 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -121,7 +121,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def metrics_redirect - environment = project.environments.with_state(:available).first + environment = project.default_environment if environment redirect_to environment_metrics_path(environment) diff --git a/app/models/project.rb b/app/models/project.rb index d91d7dcfe9a..c2afd2dfec5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1774,6 +1774,15 @@ class Project < ActiveRecord::Base end end + def default_environment + production_first = "(CASE WHEN name = 'production' THEN 0 ELSE 1 END), id ASC" + + environments + .with_state(:available) + .reorder(production_first) + .first + end + def secret_variables_for(ref:, environment: nil) # EE would use the environment if protected_for?(ref) |