diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-10-04 16:55:07 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-10-04 16:55:07 +0300 |
commit | 385817a11f568ca8fa165eaf57fa88789fc6fcd5 (patch) | |
tree | 66c5eed2305897a6ad1e58b6724832f9cd927e4d /app/models | |
parent | 88fa5916ffa0aea491cd339272ed7437c3f52dc7 (diff) | |
parent | 901c994b7a4481437f8fe91583d2ed3f19e4775e (diff) |
Merge branch 'zj-save-environment-deployment-refs' into 'master'
Save a fetchable ref per deployement
cc @DouweM @ayufan
See merge request !6618
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deployment.rb | 12 | ||||
-rw-r--r-- | app/models/environment.rb | 4 | ||||
-rw-r--r-- | app/models/repository.rb | 4 |
3 files changed, 17 insertions, 3 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 07d7e19e70d..82b27b78229 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -11,7 +11,7 @@ class Deployment < ActiveRecord::Base delegate :name, to: :environment, prefix: true - after_save :keep_around_commit + after_save :create_ref def commit project.commit(sha) @@ -29,8 +29,8 @@ class Deployment < ActiveRecord::Base self == environment.last_deployment end - def keep_around_commit - project.repository.keep_around(self.sha) + def create_ref + project.repository.create_ref(ref, ref_path) end def manual_actions @@ -76,4 +76,10 @@ class Deployment < ActiveRecord::Base where.not(id: self.id). take end + + private + + def ref_path + File.join(environment.ref_path, 'deployments', id.to_s) + end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 49e0a20640c..f0f3ee23223 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -47,4 +47,8 @@ class Environment < ActiveRecord::Base def update_merge_request_metrics? self.name == "production" end + + def ref_path + "refs/environments/#{Shellwords.shellescape(name)}" + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 51557228ab9..eb574555df6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -997,6 +997,10 @@ class Repository Gitlab::Popen.popen(args, path_to_repo) end + def create_ref(ref, ref_path) + fetch_ref(path_to_repo, ref, ref_path) + end + def update_branch_with_hooks(current_user, branch) update_autocrlf_option |