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:
authorStan Hu <stanhu@gmail.com>2018-07-20 19:45:59 +0300
committerStan Hu <stanhu@gmail.com>2018-07-20 19:45:59 +0300
commit69fe32a51c1f0299663177cad47641c50af5caec (patch)
treec9ba18557b5a2cb1f3dd6f5cd95fc4e87b3691c4
parentc73db33f1eb33919b00f88989dfc199c063da4a4 (diff)
Disable recovery of missing SHAs by default
-rw-r--r--lib/gitlab/bitbucket_server_import/importer.rb11
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importer_spec.rb2
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb
index b33923dd80c..aa164f1a61a 100644
--- a/lib/gitlab/bitbucket_server_import/importer.rb
+++ b/lib/gitlab/bitbucket_server_import/importer.rb
@@ -2,6 +2,7 @@ module Gitlab
module BitbucketServerImport
class Importer
include Gitlab::ShellAdapter
+ attr_reader :recover_missing_commits
attr_reader :project, :project_key, :repository_slug, :client, :errors, :users
REMOTE_NAME = 'bitbucket_server'.freeze
@@ -17,8 +18,14 @@ module Gitlab
[:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head']
end
- def initialize(project)
+ # Unlike GitHub, you can't grab the commit SHAs for pull requests that
+ # have been closed but not merged even though Bitbucket has these
+ # commits internally. We can recover these pull requests by creating a
+ # branch with the Bitbucket REST API, but by default we turn this
+ # behavior off.
+ def initialize(project, recover_missing_commits: false)
@project = project
+ @recover_missing_commits = recover_missing_commits
@project_key = project.import_data.data['project_key']
@repository_slug = project.import_data.data['repo_slug']
@client = BitbucketServer::Client.new(project.import_data.credentials)
@@ -141,7 +148,7 @@ module Gitlab
# may take a number of network round-trips. Do this in batches so that we can
# avoid doing a git fetch for every new branch.
pull_requests.each_slice(BATCH_SIZE) do |batch|
- restore_branches(batch)
+ restore_branches(batch) if recover_missing_commits
batch.each do |pull_request|
begin
diff --git a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
index 5c9767bcfec..20b0dcdd8a0 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
@@ -9,7 +9,7 @@ describe Gitlab::BitbucketServerImport::Importer do
let(:repo_slug) { 'rouge' }
let(:sample) { RepoHelpers.sample_compare }
- subject { described_class.new(project) }
+ subject { described_class.new(project, recover_missing_commits: true) }
before do
data = project.create_or_update_import_data(