diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-13 14:14:55 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-19 10:05:35 +0200 |
commit | a4638dddf22797f46d72ea7b73c8453ba68645ab (patch) | |
tree | 3b270989070a48e9e1ea3f983070168f863c4bd1 /app/models/environment.rb | |
parent | 1d51bc7dfd04886fa5af69a60bb509691d697813 (diff) | |
download | gitlab-ce-a4638dddf22797f46d72ea7b73c8453ba68645ab.tar.gz |
Add support for dynamic environments
Environments that can have a URL with predefined CI variables.
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 75e6f869786..33c9abf382a 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -4,6 +4,7 @@ class Environment < ActiveRecord::Base has_many :deployments before_validation :nullify_external_url + before_save :set_environment_type validates :name, presence: true, @@ -26,6 +27,17 @@ class Environment < ActiveRecord::Base self.external_url = nil if self.external_url.blank? end + def set_environment_type + names = name.split('/') + + self.environment_type = + if names.many? + names.first + else + nil + end + end + def includes_commit?(commit) return false unless last_deployment |