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/services/issuable/clone/base_service.rb')
-rw-r--r--app/services/issuable/clone/base_service.rb40
1 files changed, 22 insertions, 18 deletions
diff --git a/app/services/issuable/clone/base_service.rb b/app/services/issuable/clone/base_service.rb
index ce9918a4b56..98c50347719 100644
--- a/app/services/issuable/clone/base_service.rb
+++ b/app/services/issuable/clone/base_service.rb
@@ -3,13 +3,13 @@
module Issuable
module Clone
class BaseService < IssuableBaseService
- attr_reader :original_entity, :new_entity, :target_project
+ attr_reader :original_entity, :new_entity
alias_method :old_project, :project
- def execute(original_entity, target_project = nil)
+ def execute(original_entity, target_parent)
@original_entity = original_entity
- @target_project = target_project
+ @target_parent = target_parent
# Using transaction because of a high resources footprint
# on rewriting notes (unfolding references)
@@ -25,19 +25,21 @@ module Issuable
private
- def copy_award_emoji
- AwardEmojis::CopyService.new(original_entity, new_entity).execute
- end
+ attr_reader :target_parent
- def copy_notes
- Notes::CopyService.new(current_user, original_entity, new_entity).execute
+ def rewritten_old_entity_attributes(include_milestone: true)
+ Gitlab::Issuable::Clone::AttributesRewriter.new(
+ current_user,
+ original_entity,
+ target_parent
+ ).execute(include_milestone: include_milestone)
end
def update_new_entity
update_new_entity_description
- update_new_entity_attributes
copy_award_emoji
copy_notes
+ copy_resource_events
end
def update_new_entity_description
@@ -52,8 +54,16 @@ module Issuable
new_entity.update!(update_description_params)
end
- def update_new_entity_attributes
- AttributesRewriter.new(current_user, original_entity, new_entity).execute
+ def copy_award_emoji
+ AwardEmojis::CopyService.new(original_entity, new_entity).execute
+ end
+
+ def copy_notes
+ Notes::CopyService.new(current_user, original_entity, new_entity).execute
+ end
+
+ def copy_resource_events
+ Gitlab::Issuable::Clone::CopyResourceEventsService.new(current_user, original_entity, new_entity).execute
end
def update_old_entity
@@ -74,14 +84,8 @@ module Issuable
new_entity.resource_parent
end
- def group
- if new_entity.project&.group && current_user.can?(:read_group, new_entity.project.group)
- new_entity.project.group
- end
- end
-
def relative_position
- return if original_entity.project.root_ancestor.id != target_project.root_ancestor.id
+ return if original_entity.project.root_ancestor.id != target_parent.root_ancestor.id
original_entity.relative_position
end