diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:24:51 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:24:51 +0300 |
commit | 40528a1326208a04f95f18d6dcc7547cdb8ae0c3 (patch) | |
tree | 9e3f7ac86edfe03b218e3cd12ed9cae8b2b539f2 /app/models/environment.rb | |
parent | 0e1f39d8cee3a6d23fccb195f8257178df840805 (diff) | |
parent | 052de0600c6b137e6f9df08250b4cf5f38280295 (diff) |
Merge remote-tracking branch 'origin/master' into 22191-delete-dynamic-envs-mr
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 6ec498ea2b7..07f14a7ad8d 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -66,7 +66,22 @@ class Environment < ActiveRecord::Base self.name == "production" end + def first_deployment_for(commit) + ref = project.repository.ref_name_for_sha(ref_path, commit.sha) + + return nil unless ref + + deployment_id = ref.split('/').last + deployments.find(deployment_id) + end + def ref_path "refs/environments/#{Shellwords.shellescape(name)}" end + + def formatted_external_url + return nil unless external_url + + external_url.gsub(/\A.*?:\/\//, '') + end end |