Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-10-04 17:03:13 +0300
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-10-14 12:07:00 +0300
commit6a4f71008390752e6b5574a9e9bdf277732d852d (patch)
treecedc380844ee38ec20b89916a6038d3c4aeaa1c1 /app/models/environment.rb
parente4c74ffe3ed93815b131445796e63e2127eb8c3e (diff)
Show what time ago a MR was deployed
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r--app/models/environment.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb
index f0f3ee23223..1c7d06906f3 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -48,6 +48,14 @@ class Environment < ActiveRecord::Base
self.name == "production"
end
+ def deployment_id_for(commit)
+ ref = project.repository.ref_name_for_sha(ref_path, commit.sha)
+
+ return nil unless ref
+
+ ref.split('/').last.to_i
+ end
+
def ref_path
"refs/environments/#{Shellwords.shellescape(name)}"
end