Class: Gitlab::BitbucketImport::Importer
- Inherits:
-
Object
- Object
- Gitlab::BitbucketImport::Importer
- Defined in:
- lib/gitlab/bitbucket_import/importer.rb
Constant Summary collapse
- LABELS =
[{ title: 'bug', color: '#FF0000' }, { title: 'enhancement', color: '#428BCA' }, { title: 'proposal', color: '#69D100' }, { title: 'task', color: '#7F8C8D' }].freeze
- ALREADY_IMPORTED_CACHE_KEY =
'bitbucket_cloud-importer/already-imported/%{project}/%{collection}'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #create_labels ⇒ Object
- #execute ⇒ Object
-
#initialize(project) ⇒ Importer
constructor
A new instance of Importer.
Constructor Details
#initialize(project) ⇒ Importer
Returns a new instance of Importer.
15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 15 def initialize(project) @project = project @client = Bitbucket::Client.new(project.import_data.credentials) @formatter = Gitlab::ImportFormatter.new @labels = {} @errors = [] @users = {} end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 11 def client @client end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 11 def errors @errors end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
11 12 13 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 11 def project @project end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
11 12 13 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 11 def users @users end |
Instance Method Details
#create_labels ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 34 def create_labels LABELS.each do |label_params| label = ::Labels::FindOrCreateService.new(nil, project, label_params).execute(skip_authorization: true) if label.valid? @labels[label_params[:title]] = label else raise "Failed to create label \"#{label_params[:title]}\" for project \"#{project.full_name}\"" end end end |
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/gitlab/bitbucket_import/importer.rb', line 24 def execute import_wiki import_issues import_pull_requests handle_errors metrics.track_finished_import true end |