Class: Gitlab::BitbucketServerImport::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/bitbucket_server_import/importer.rb

Defined Under Namespace

Classes: TempBranch

Constant Summary collapse

REMOTE_NAME =
'bitbucket_server'
BATCH_SIZE =
100

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, recover_missing_commits: false) ⇒ Importer

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.


28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 28

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)
  @formatter = Gitlab::ImportFormatter.new
  @errors = []
  @users = {}
  @temp_branches = []
  @logger = Gitlab::Import::Logger.build
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def client
  @client
end

#errorsObject (readonly)

Returns the value of attribute errors


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def errors
  @errors
end

#loggerObject

Returns the value of attribute logger


8
9
10
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 8

def logger
  @logger
end

#projectObject (readonly)

Returns the value of attribute project


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def project
  @project
end

#project_keyObject (readonly)

Returns the value of attribute project_key


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def project_key
  @project_key
end

#recover_missing_commitsObject (readonly)

Returns the value of attribute recover_missing_commits


6
7
8
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 6

def recover_missing_commits
  @recover_missing_commits
end

#repository_slugObject (readonly)

Returns the value of attribute repository_slug


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def repository_slug
  @repository_slug
end

#usersObject (readonly)

Returns the value of attribute users


7
8
9
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7

def users
  @users
end

Class Method Details

.imports_repository?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 15

def self.imports_repository?
  true
end

.refmapObject


19
20
21
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 19

def self.refmap
  [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head']
end

Instance Method Details

#executeObject


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 41

def execute
  import_repository
  import_pull_requests
  delete_temp_branches
  handle_errors
  metrics.track_finished_import

  log_info(stage: "complete")

  true
end