diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
commit | 419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch) | |
tree | 1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /lib/gitlab/bitbucket_import/importer.rb | |
parent | 1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff) |
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'lib/gitlab/bitbucket_import/importer.rb')
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 7f228c19b6b..9f87bb2347c 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -16,6 +16,7 @@ module Gitlab @project = project @client = Bitbucket::Client.new(project.import_data.credentials) @formatter = Gitlab::ImportFormatter.new + @ref_converter = Gitlab::BitbucketImport::RefConverter.new(project) @labels = {} @errors = [] @users = {} @@ -31,6 +32,26 @@ module Gitlab true end + 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 + + def import_pull_request_comments(pull_request, merge_request) + comments = client.pull_request_comments(repo, pull_request.iid) + + inline_comments, pr_comments = comments.partition(&:inline?) + + import_inline_comments(inline_comments, pull_request, merge_request) + import_standalone_pr_comments(pr_comments, merge_request) + end + private def already_imported?(collection, iid) @@ -166,7 +187,7 @@ module Gitlab note = '' note += @formatter.author_line(comment.author) unless find_user_id(comment.author) - note += comment.note + note += @ref_converter.convert_note(comment.note.to_s) begin gitlab_issue.notes.create!( @@ -182,17 +203,6 @@ module Gitlab end end - 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 - def import_pull_requests pull_requests = client.pull_requests(repo) @@ -242,15 +252,6 @@ module Gitlab store_pull_request_error(pull_request, e) end - def import_pull_request_comments(pull_request, merge_request) - comments = client.pull_request_comments(repo, pull_request.iid) - - inline_comments, pr_comments = comments.partition(&:inline?) - - import_inline_comments(inline_comments, pull_request, merge_request) - import_standalone_pr_comments(pr_comments, merge_request) - end - def import_inline_comments(inline_comments, pull_request, merge_request) position_map = {} discussion_map = {} @@ -319,8 +320,7 @@ module Gitlab def comment_note(comment) author = @formatter.author_line(comment.author) unless find_user_id(comment.author) - - author.to_s + comment.note.to_s + author.to_s + @ref_converter.convert_note(comment.note.to_s) end def log_base_data |