diff options
author | James Lopez <james@jameslopez.es> | 2016-08-05 10:56:27 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-08-09 11:03:02 +0200 |
commit | f8e854798032d71e3b3cb2bcf49cf104e5d0e611 (patch) | |
tree | 3dadab243be69662f8e41afbfb8fe98cc008c138 /lib | |
parent | 551ffc0a4d25a381e9f8f6a8d6f2793bb87f3145 (diff) | |
download | gitlab-ce-fix/import-mr-source.tar.gz |
fix MR source project assignmentfix/import-mr-source
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/relation_factory.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb index 5e56b3d1aa7..b0726268ca6 100644 --- a/lib/gitlab/import_export/relation_factory.rb +++ b/lib/gitlab/import_export/relation_factory.rb @@ -102,17 +102,19 @@ module Gitlab def update_project_references project_id = @relation_hash.delete('project_id') + # If source and target are the same, populate them with the new project ID. + if @relation_hash['source_project_id'] + @relation_hash['source_project_id'] = same_source_and_target? ? project_id : -1 + end + # project_id may not be part of the export, but we always need to populate it if required. @relation_hash['project_id'] = project_id @relation_hash['gl_project_id'] = project_id if @relation_hash['gl_project_id'] @relation_hash['target_project_id'] = project_id if @relation_hash['target_project_id'] - @relation_hash['source_project_id'] = -1 if @relation_hash['source_project_id'] + end - # If source and target are the same, populate them with the new project ID. - if @relation_hash['source_project_id'] && @relation_hash['target_project_id'] && - @relation_hash['target_project_id'] == @relation_hash['source_project_id'] - @relation_hash['source_project_id'] = project_id - end + def same_source_and_target? + @relation_hash['target_project_id'] && @relation_hash['target_project_id'] == @relation_hash['source_project_id'] end def reset_ci_tokens |