diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 06:07:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 06:07:58 +0000 |
commit | 9c83aadd2604e7e6cb1f84683f951e6b12872618 (patch) | |
tree | c0a14c87378e832e87580be382e1c8ccea188b71 /app/models/deployment.rb | |
parent | 23bc19cb73aad969c9636b8b935111645e809e54 (diff) | |
download | gitlab-ce-9c83aadd2604e7e6cb1f84683f951e6b12872618.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 707c4e8157d..ba65acff7f3 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -7,6 +7,7 @@ class Deployment < ApplicationRecord include UpdatedAtFilterable include Importable include Gitlab::Utils::StrongMemoize + include FastDestroyAll belongs_to :project, required: true belongs_to :environment, required: true @@ -113,6 +114,26 @@ class Deployment < ApplicationRecord success.find_by!(iid: iid) end + class << self + ## + # FastDestroyAll concerns + def begin_fast_destroy + preload(:project).find_each.map do |deployment| + [deployment.project, deployment.ref_path] + end + end + + ## + # FastDestroyAll concerns + def finalize_fast_destroy(params) + by_project = params.group_by(&:shift) + + by_project.each do |project, ref_paths| + project.repository.delete_refs(*ref_paths.flatten) + end + end + end + def commit project.commit(sha) end @@ -280,12 +301,12 @@ class Deployment < ApplicationRecord errors.add(:ref, _('The branch or tag does not exist')) end - private - def ref_path File.join(environment.ref_path, 'deployments', iid.to_s) end + private + def legacy_finished_at self.created_at if success? && !read_attribute(:finished_at) end |