diff options
author | James Lopez <james@jameslopez.es> | 2016-03-22 12:25:28 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-03-22 12:25:28 +0100 |
commit | 23146fca1878c9f6e90deed6856d3da2c731d513 (patch) | |
tree | ee66b2b93b90cceac163f0b55b551ea5f463100a /lib | |
parent | 1b8d995492baca8984bde950e0449dad6342befc (diff) | |
download | gitlab-ce-23146fca1878c9f6e90deed6856d3da2c731d513.tar.gz |
update bitbucket importer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 46e51a4bf6d..36110962e0c 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -5,11 +5,14 @@ module Gitlab def initialize(project) @project = project - import_data = project.import_data.try(:data) - bb_session = import_data["bb_session"] if import_data - @client = Client.new(bb_session["bitbucket_access_token"], - bb_session["bitbucket_access_token_secret"]) - @formatter = Gitlab::ImportFormatter.new + 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'] + @client = Client.new(token, token_secret) + @formatter = Gitlab::ImportFormatter.new + else + raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{@project.id}" + end end def execute @@ -24,6 +27,10 @@ module Gitlab private + def import_data_credentials + @import_data_credentials ||= project.import_data.credentials if project.import_data + end + def gl_user_id(project, bitbucket_id) if bitbucket_id user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", bitbucket_id.to_s) diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index 0b1ed510229..a5d3ab5fcf1 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -8,7 +8,7 @@ module Gitlab def initialize(project) @project = project if import_data_credentials - @client = Client.new(import_data_credentials[:user]) + @client = Client.new(import_data_credentials['user']) @formatter = Gitlab::ImportFormatter.new else raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{@project.id}" |