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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-15 06:06:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-15 06:06:34 +0300
commit41d446ba3f0518097eb350b142ecfbeeb6be83e6 (patch)
tree465127e4d63fe9d0c61ab7f281737e588a04a4ae /lib/gitlab/import_export
parent386e5740f68fc7f49bc7692a28e927d6ea5ab056 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/import_export')
-rw-r--r--lib/gitlab/import_export/group_project_object_builder.rb11
-rw-r--r--lib/gitlab/import_export/relation_factory.rb7
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/gitlab/import_export/group_project_object_builder.rb b/lib/gitlab/import_export/group_project_object_builder.rb
index de1629d0e28..b94839363df 100644
--- a/lib/gitlab/import_export/group_project_object_builder.rb
+++ b/lib/gitlab/import_export/group_project_object_builder.rb
@@ -49,11 +49,12 @@ module Gitlab
].compact
end
- # Returns Arel clause `"{table_name}"."project_id" = {project.id}`
+ # Returns Arel clause `"{table_name}"."project_id" = {project.id}` if project is present
+ # For example: merge_request has :target_project_id, and we are searching by :iid
# or, if group is present:
# `"{table_name}"."project_id" = {project.id} OR "{table_name}"."group_id" = {group.id}`
def where_clause_base
- clause = table[:project_id].eq(project.id)
+ clause = table[:project_id].eq(project.id) if project
clause = clause.or(table[:group_id].eq(group.id)) if group
clause
@@ -103,6 +104,10 @@ module Gitlab
klass == Milestone
end
+ def merge_request?
+ klass == MergeRequest
+ end
+
# If an existing group milestone used the IID
# claim the IID back and set the group milestone to use one available
# This is necessary to fix situations like the following:
@@ -124,7 +129,7 @@ module Gitlab
# Returns Arel clause for a particular model or `nil`.
def where_clause_for_klass
- # no-op
+ return attrs_to_arel(attributes.slice('iid')) if merge_request?
end
end
end
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index f8f6c3e6107..ae6b3c161ce 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -329,8 +329,6 @@ module Gitlab
def find_or_create_object!
return relation_class.find_or_create_by(project_id: @project.id) if UNIQUE_RELATIONS.include?(@relation_name)
- return find_or_create_merge_request! if @relation_name == :merge_request
-
# Can't use IDs as validation exists calling `group` or `project` attributes
finder_hash = parsed_relation_hash.tap do |hash|
hash['group'] = @project.group if relation_class.attribute_method?('group_id')
@@ -340,11 +338,6 @@ module Gitlab
GroupProjectObjectBuilder.build(relation_class, finder_hash)
end
-
- def find_or_create_merge_request!
- @project.merge_requests.find_by(iid: parsed_relation_hash['iid']) ||
- relation_class.new(parsed_relation_hash)
- end
end
end
end