提交 69fe32a5 编写于 作者: S Stan Hu

Disable recovery of missing SHAs by default

上级 c73db33f
...@@ -2,6 +2,7 @@ module Gitlab ...@@ -2,6 +2,7 @@ module Gitlab
module BitbucketServerImport module BitbucketServerImport
class Importer class Importer
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
attr_reader :recover_missing_commits
attr_reader :project, :project_key, :repository_slug, :client, :errors, :users attr_reader :project, :project_key, :repository_slug, :client, :errors, :users
REMOTE_NAME = 'bitbucket_server'.freeze REMOTE_NAME = 'bitbucket_server'.freeze
...@@ -17,8 +18,14 @@ module Gitlab ...@@ -17,8 +18,14 @@ module Gitlab
[:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head'] [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head']
end 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 @project = project
@recover_missing_commits = recover_missing_commits
@project_key = project.import_data.data['project_key'] @project_key = project.import_data.data['project_key']
@repository_slug = project.import_data.data['repo_slug'] @repository_slug = project.import_data.data['repo_slug']
@client = BitbucketServer::Client.new(project.import_data.credentials) @client = BitbucketServer::Client.new(project.import_data.credentials)
...@@ -141,7 +148,7 @@ module Gitlab ...@@ -141,7 +148,7 @@ module Gitlab
# may take a number of network round-trips. Do this in batches so that we can # 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. # avoid doing a git fetch for every new branch.
pull_requests.each_slice(BATCH_SIZE) do |batch| pull_requests.each_slice(BATCH_SIZE) do |batch|
restore_branches(batch) restore_branches(batch) if recover_missing_commits
batch.each do |pull_request| batch.each do |pull_request|
begin begin
......
...@@ -9,7 +9,7 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -9,7 +9,7 @@ describe Gitlab::BitbucketServerImport::Importer do
let(:repo_slug) { 'rouge' } let(:repo_slug) { 'rouge' }
let(:sample) { RepoHelpers.sample_compare } let(:sample) { RepoHelpers.sample_compare }
subject { described_class.new(project) } subject { described_class.new(project, recover_missing_commits: true) }
before do before do
data = project.create_or_update_import_data( data = project.create_or_update_import_data(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册