Class: Gitlab::BitbucketServerImport::Importers::PullRequestNotes::Inline

Inherits:
BaseNoteDiffImporter show all
Defined in:
lib/gitlab/bitbucket_server_import/importers/pull_request_notes/inline.rb

Constant Summary

Constants inherited from BaseNoteDiffImporter

BaseNoteDiffImporter::PARENT_COMMENT_CONTEXT_LENGTH

Constants included from Import::UsernameMentionRewriter

Import::UsernameMentionRewriter::MENTION_REGEX

Instance Method Summary collapse

Methods inherited from BaseNoteDiffImporter

#author, #build_position, #create_basic_fallback_note, #create_diff_note, #pull_request_comment_attributes

Methods inherited from BaseImporter

#initialize

Methods included from Import::PlaceholderReferences::Pusher

#push_reference, #source_user_mapped_to_human?, #source_user_mapper, #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

This class inherits a constructor from Gitlab::BitbucketServerImport::Importers::PullRequestNotes::BaseImporter

Instance Method Details

#execute(comment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/bitbucket_server_import/importers/pull_request_notes/inline.rb', line 8

def execute(comment)
  log_info(
    import_stage: 'import_inline_comments',
    message: 'starting',
    iid: merge_request.iid,
    comment_id: comment[:id]
  )

  position = build_position(merge_request, comment)
  parent = create_diff_note(merge_request, comment, position)

  return unless parent&.persisted?

  discussion_id = parent.discussion_id

  comment[:comments].each do |reply|
    create_diff_note(merge_request, reply, position, discussion_id)
  end

  log_info(
    import_stage: 'import_inline_comments',
    message: 'finished',
    iid: merge_request.iid,
    comment_id: comment[:id]
  )
end