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:
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb25
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