summaryrefslogtreecommitdiff
path: root/lib/gitlab/bitbucket_import/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/bitbucket_import/client.rb')
-rw-r--r--lib/gitlab/bitbucket_import/client.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/bitbucket_import/client.rb b/lib/gitlab/bitbucket_import/client.rb
index d88a6eaac6b..9bb507b5edd 100644
--- a/lib/gitlab/bitbucket_import/client.rb
+++ b/lib/gitlab/bitbucket_import/client.rb
@@ -5,6 +5,17 @@ module Gitlab
attr_reader :consumer, :api
+ def self.from_project(project)
+ import_data_credentials = project.import_data.credentials if project.import_data
+ if import_data_credentials && import_data_credentials[:bb_session]
+ token = import_data_credentials[:bb_session][:bitbucket_access_token]
+ token_secret = import_data_credentials[:bb_session][:bitbucket_access_token_secret]
+ new(token, token_secret)
+ else
+ raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{@project.id}"
+ end
+ end
+
def initialize(access_token = nil, access_token_secret = nil)
@consumer = ::OAuth::Consumer.new(
config.app_id,
@@ -54,7 +65,7 @@ module Gitlab
def issues(project_identifier)
all_issues = []
offset = 0
- per_page = 50 # Maximum number allowed by Bitbucket
+ per_page = 50 # Maximum number allowed by Bitbucket
index = 0
begin
@@ -120,7 +131,7 @@ module Gitlab
end
def config
- Gitlab.config.omniauth.providers.find { |provider| provider.name == "bitbucket"}
+ Gitlab.config.omniauth.providers.find { |provider| provider.name == "bitbucket" }
end
def bitbucket_options