Class: Gitlab::BitbucketServerImport::Importer
- Inherits:
-
Object
- Object
- Gitlab::BitbucketServerImport::Importer
- Defined in:
- lib/gitlab/bitbucket_server_import/importer.rb
Defined Under Namespace
Classes: TempBranch
Constant Summary collapse
- BATCH_SIZE =
100
- ALREADY_IMPORTED_CACHE_KEY =
The base cache key to use for tracking already imported objects.
'bitbucket_server-importer/already-imported/%{project}/%{collection}'
Instance Attribute Summary collapse
-
#already_imported_cache_key ⇒ Object
readonly
Returns the value of attribute already_imported_cache_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#project_key ⇒ Object
readonly
Returns the value of attribute project_key.
-
#recover_missing_commits ⇒ Object
readonly
Returns the value of attribute recover_missing_commits.
-
#repository_slug ⇒ Object
readonly
Returns the value of attribute repository_slug.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Class Method Summary collapse
Instance Method Summary collapse
- #collection_method ⇒ Object
- #execute ⇒ Object
-
#initialize(project, recover_missing_commits: false) ⇒ Importer
constructor
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.
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.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 31 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 @already_imported_cache_key = ALREADY_IMPORTED_CACHE_KEY % { project: project.id, collection: collection_method } end |
Instance Attribute Details
#already_imported_cache_key ⇒ Object (readonly)
Returns the value of attribute already_imported_cache_key.
7 8 9 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7 def already_imported_cache_key @already_imported_cache_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7 def client @client end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 7 def errors @errors end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 8 def logger @logger end |
#project ⇒ Object (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_key ⇒ Object (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_commits ⇒ Object (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_slug ⇒ Object (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 |
#users ⇒ Object (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
17 18 19 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 17 def self.imports_repository? true end |
.refmap ⇒ Object
21 22 23 24 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 21 def self.refmap # We omit :heads and :tags since these are fetched in the import_repository ['+refs/pull-requests/*/to:refs/merge-requests/*/head'] end |
Instance Method Details
#collection_method ⇒ Object
46 47 48 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 46 def collection_method :pull_requests end |
#execute ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gitlab/bitbucket_server_import/importer.rb', line 50 def execute import_repository import_pull_requests download_lfs_objects delete_temp_branches handle_errors metrics.track_finished_import log_info(stage: "complete") Gitlab::Cache::Import::Caching.expire(already_imported_cache_key, Gitlab::Cache::Import::Caching::SHORTER_TIMEOUT) true end |