diff options
Diffstat (limited to 'lib/gitlab/github_import')
-rw-r--r-- | lib/gitlab/github_import/branch_formatter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/github_import/issuable_formatter.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/github_import/pull_request_formatter.rb | 14 |
4 files changed, 18 insertions, 6 deletions
diff --git a/lib/gitlab/github_import/branch_formatter.rb b/lib/gitlab/github_import/branch_formatter.rb index 0a8d05b5fe1..5d29e698b27 100644 --- a/lib/gitlab/github_import/branch_formatter.rb +++ b/lib/gitlab/github_import/branch_formatter.rb @@ -18,7 +18,7 @@ module Gitlab end def commit_exists? - project.repository.commit(sha).present? + project.repository.branch_names_contains(sha).include?(ref) end def short_id diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index d95ff4fd104..eea4a91f17d 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -171,6 +171,8 @@ module Gitlab end def clean_up_restored_branches(pull_request) + return if pull_request.opened? + remove_branch(pull_request.source_branch_name) unless pull_request.source_branch_exists? remove_branch(pull_request.target_branch_name) unless pull_request.target_branch_exists? end @@ -285,7 +287,7 @@ module Gitlab def fetch_resources(resource_type, *opts) return if imported?(resource_type) - opts.last.merge!(page: current_page(resource_type)) + opts.last[:page] = current_page(resource_type) client.public_send(resource_type, *opts) do |resources| yield resources diff --git a/lib/gitlab/github_import/issuable_formatter.rb b/lib/gitlab/github_import/issuable_formatter.rb index 29fb0f9d333..27b171d6ddb 100644 --- a/lib/gitlab/github_import/issuable_formatter.rb +++ b/lib/gitlab/github_import/issuable_formatter.rb @@ -7,9 +7,7 @@ module Gitlab raise NotImplementedError end - def number - raw_data.number - end + delegate :number, to: :raw_data def find_condition { iid: number } diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb index 4ea0200e89b..add7236e339 100644 --- a/lib/gitlab/github_import/pull_request_formatter.rb +++ b/lib/gitlab/github_import/pull_request_formatter.rb @@ -38,7 +38,11 @@ module Gitlab def source_branch_name @source_branch_name ||= begin - source_branch_exists? ? source_branch_ref : "pull/#{number}/#{source_branch_ref}" + if cross_project? + "pull/#{number}/#{source_branch_repo.full_name}/#{source_branch_ref}" + else + source_branch_exists? ? source_branch_ref : "pull/#{number}/#{source_branch_ref}" + end end end @@ -52,6 +56,14 @@ module Gitlab end end + def cross_project? + source_branch.repo.id != target_branch.repo.id + end + + def opened? + state == 'opened' + end + private def state |