summaryrefslogtreecommitdiff
path: root/app/services/issuable
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/services/issuable
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/services/issuable')
-rw-r--r--app/services/issuable/clone/base_service.rb11
-rw-r--r--app/services/issuable/process_assignees.rb36
2 files changed, 45 insertions, 2 deletions
diff --git a/app/services/issuable/clone/base_service.rb b/app/services/issuable/clone/base_service.rb
index b2f9c083b5b..3c2bc527b12 100644
--- a/app/services/issuable/clone/base_service.rb
+++ b/app/services/issuable/clone/base_service.rb
@@ -3,12 +3,13 @@
module Issuable
module Clone
class BaseService < IssuableBaseService
- attr_reader :original_entity, :new_entity
+ attr_reader :original_entity, :new_entity, :target_project
alias_method :old_project, :project
- def execute(original_entity, new_project = nil)
+ def execute(original_entity, target_project = nil)
@original_entity = original_entity
+ @target_project = target_project
# Using transaction because of a high resources footprint
# on rewriting notes (unfolding references)
@@ -77,6 +78,12 @@ module Issuable
new_entity.project.group
end
end
+
+ def relative_position
+ return if original_entity.project.root_ancestor.id != target_project.root_ancestor.id
+
+ original_entity.relative_position
+ end
end
end
end
diff --git a/app/services/issuable/process_assignees.rb b/app/services/issuable/process_assignees.rb
new file mode 100644
index 00000000000..c9c6b0bed85
--- /dev/null
+++ b/app/services/issuable/process_assignees.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+# This follows the rules specified in the specs.
+# See spec/requests/api/graphql/mutations/merge_requests/set_assignees_spec.rb
+
+module Issuable
+ class ProcessAssignees
+ def initialize(assignee_ids:, add_assignee_ids:, remove_assignee_ids:, existing_assignee_ids: nil, extra_assignee_ids: nil)
+ @assignee_ids = assignee_ids
+ @add_assignee_ids = add_assignee_ids
+ @remove_assignee_ids = remove_assignee_ids
+ @existing_assignee_ids = existing_assignee_ids || []
+ @extra_assignee_ids = extra_assignee_ids || []
+ end
+
+ def execute
+ if assignee_ids.blank?
+ updated_new_assignees = new_assignee_ids
+ updated_new_assignees |= add_assignee_ids if add_assignee_ids
+ updated_new_assignees -= remove_assignee_ids if remove_assignee_ids
+ else
+ updated_new_assignees = assignee_ids
+ end
+
+ updated_new_assignees.uniq
+ end
+
+ private
+
+ attr_accessor :assignee_ids, :add_assignee_ids, :remove_assignee_ids, :existing_assignee_ids, :extra_assignee_ids
+
+ def new_assignee_ids
+ existing_assignee_ids | extra_assignee_ids
+ end
+ end
+end