Class: Gitlab::BitbucketServerImport::Importers::PullRequestImporter
- Inherits:
-
Object
- Object
- Gitlab::BitbucketServerImport::Importers::PullRequestImporter
- Defined in:
- lib/gitlab/bitbucket_server_import/importers/pull_request_importer.rb
Constant Summary
Constants included from Import::UsernameMentionRewriter
Import::UsernameMentionRewriter::MENTION_REGEX
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, hash) ⇒ PullRequestImporter
constructor
A new instance of PullRequestImporter.
Methods included from Import::PlaceholderReferences::Pusher
#map_to_personal_namespace_owner?, #push_reference, #push_reference_with_composite_key, #push_references_by_ids, #user_mapping_enabled?
Methods included from Import::UsernameMentionRewriter
#update_username_mentions, #wrap_mentions_in_backticks
Methods included from Loggable
#log_debug, #log_error, #log_info, #log_warn
Constructor Details
#initialize(project, hash) ⇒ PullRequestImporter
Returns a new instance of PullRequestImporter.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gitlab/bitbucket_server_import/importers/pull_request_importer.rb', line 11 def initialize(project, hash) @project = project @formatter = Gitlab::ImportFormatter.new @user_finder = UserFinder.new(project) # Object should behave as a object so we can remove object.is_a?(Hash) check # This will be fixed in https://gitlab.com/gitlab-org/gitlab/-/issues/412328 @object = hash.with_indifferent_access @reviewer_references = {} end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gitlab/bitbucket_server_import/importers/pull_request_importer.rb', line 22 def execute log_info(import_stage: 'import_pull_request', message: 'starting', iid: object[:iid]) attributes = { iid: object[:iid], title: object[:title], description: description, reviewer_ids: reviewers, source_project_id: project.id, source_branch: Gitlab::Git.ref_name(object[:source_branch_name]), source_branch_sha: source_branch_sha, target_project_id: project.id, target_branch: Gitlab::Git.ref_name(object[:target_branch_name]), target_branch_sha: object[:target_branch_sha], state_id: MergeRequest.available_states[object[:state]], author_id: (object), created_at: object[:created_at], updated_at: object[:updated_at], imported_from: ::Import::HasImportSource::IMPORT_SOURCES[:bitbucket_server] } creator = Gitlab::Import::MergeRequestCreator.new(project) merge_request = creator.execute(attributes) push_reference(project, merge_request, :author_id, object[:author_username]) push_reviewer_references(merge_request) # Create refs/merge-requests/iid/head reference for the merge request merge_request.fetch_ref! log_info(import_stage: 'import_pull_request', message: 'finished', iid: object[:iid]) end |