diff options
-rw-r--r-- | app/controllers/import/bitbucket_server_controller.rb | 4 | ||||
-rw-r--r-- | lib/bitbucket_server/client.rb | 25 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/comment.rb | 2 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/pull_request_comment.rb | 19 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/repo.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_server_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_server_import/project_creator.rb | 2 |
7 files changed, 15 insertions, 41 deletions
diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb index b9397502414..36229bcafc9 100644 --- a/app/controllers/import/bitbucket_server_controller.rb +++ b/app/controllers/import/bitbucket_server_controller.rb @@ -60,8 +60,8 @@ class Import::BitbucketServerController < Import::BaseController def bitbucket_auth unless session[bitbucket_server_url_key].present? && - session[bitbucket_server_username_key].present? && - session[personal_access_token_key].present? + session[bitbucket_server_username_key].present? && + session[personal_access_token_key].present? redirect_to new_import_bitbucket_server_path end end diff --git a/lib/bitbucket_server/client.rb b/lib/bitbucket_server/client.rb index c3cb1608187..e632adea68c 100644 --- a/lib/bitbucket_server/client.rb +++ b/lib/bitbucket_server/client.rb @@ -6,16 +6,6 @@ module BitbucketServer @connection = Connection.new(options) end - def issues(repo) - path = "/repositories/#{repo}/issues" - get_collection(path, :issue) - end - - def issue_comments(repo, issue_id) - path = "/repositories/#{repo}/issues/#{issue_id}/comments" - get_collection(path, :comment) - end - def pull_requests(project_key, repo) path = "/projects/#{project_key}/repos/#{repo}/pull-requests?state=ALL" get_collection(path, :pull_request) @@ -23,13 +13,7 @@ module BitbucketServer def activities(project_key, repo, pull_request) path = "/projects/#{project_key}/repos/#{repo}/pull-requests/#{pull_request}/activities" - - collection = get_collection(path, :activity) - end - - def pull_request_diff(project_key, repo, pull_request) - path = "/projects/#{project_key}/repos/#{repo}/pull-requests/#{pull_request}/diff" - connection.get(path) + get_collection(path, :activity) end def repo(project, repo_name) @@ -43,13 +27,6 @@ module BitbucketServer get_collection(path, :repo) end - def user - @user ||= begin - parsed_response = connection.get('/user') - BitbucketServer::Representation::User.new(parsed_response) - end - end - private def get_collection(path, type) diff --git a/lib/bitbucket_server/representation/comment.rb b/lib/bitbucket_server/representation/comment.rb index 07a8b359db7..44f76139fc4 100644 --- a/lib/bitbucket_server/representation/comment.rb +++ b/lib/bitbucket_server/representation/comment.rb @@ -55,7 +55,7 @@ module BitbucketServer comments.each do |comment| new_comments = comment.delete('comments') workset << new_comments if new_comments - all_comments << Comment.new({ 'comment' => comment}) + all_comments << Comment.new({ 'comment' => comment }) end end diff --git a/lib/bitbucket_server/representation/pull_request_comment.rb b/lib/bitbucket_server/representation/pull_request_comment.rb index 3763ba13816..c7d08e604fd 100644 --- a/lib/bitbucket_server/representation/pull_request_comment.rb +++ b/lib/bitbucket_server/representation/pull_request_comment.rb @@ -35,7 +35,7 @@ module BitbucketServer end def added? - line_type == 'ADDED' + line_type == 'ADDED' end def removed? @@ -67,17 +67,16 @@ module BitbucketServer end def line_position - @line_position ||= - diff_hunks.each do |hunk| - segments = hunk.fetch('segments', []) - segments.each do |segment| - lines = segment.fetch('lines', []) - lines.each do |line| - if line['commentIds']&.include?(id) - return [line['source'], line['destination']] - end + @line_position ||= diff_hunks.each do |hunk| + segments = hunk.fetch('segments', []) + segments.each do |segment| + lines = segment.fetch('lines', []) + lines.each do |line| + if line['commentIds']&.include?(id) + return [line['source'], line['destination']] end end + end end end diff --git a/lib/bitbucket_server/representation/repo.rb b/lib/bitbucket_server/representation/repo.rb index 38778645966..2f3a60b204b 100644 --- a/lib/bitbucket_server/representation/repo.rb +++ b/lib/bitbucket_server/representation/repo.rb @@ -1,8 +1,6 @@ module BitbucketServer module Representation class Repo < Representation::Base - attr_reader :owner, :slug - def initialize(raw) super(raw) end diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index 5f6230438bc..9bc6de2ea5d 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -69,7 +69,7 @@ module Gitlab description: description, source_project: project, source_branch: Gitlab::Git.ref_name(pull_request.source_branch_name), - source_branch_sha: pull_request.source_branch_sha, + source_branch_sha: source_branch_sha, target_project: project, target_branch: Gitlab::Git.ref_name(pull_request.target_branch_name), target_branch_sha: target_branch_sha, diff --git a/lib/gitlab/bitbucket_server_import/project_creator.rb b/lib/gitlab/bitbucket_server_import/project_creator.rb index 3dc4bd80f32..031ae29120d 100644 --- a/lib/gitlab/bitbucket_server_import/project_creator.rb +++ b/lib/gitlab/bitbucket_server_import/project_creator.rb @@ -27,7 +27,7 @@ module Gitlab import_data: { credentials: session_data, data: { project_key: project_key, - repo_slug: repo_slug }, + repo_slug: repo_slug } }, skip_wiki: true ).execute |