Commit 6d12d79d authored by James Lopez's avatar James Lopez

fix fogbugz import

parent 075b56aa
...@@ -17,4 +17,8 @@ class ProjectImportData < ActiveRecord::Base ...@@ -17,4 +17,8 @@ class ProjectImportData < ActiveRecord::Base
serialize :data, JSON serialize :data, JSON
validates :project, presence: true validates :project, presence: true
def stringified_credentials
JSON[credentials.to_json]
end
end end
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
import_data = project.import_data.try(:data) import_data = project.import_data.try(:data)
repo_data = import_data['repo'] if import_data repo_data = import_data['repo'] if import_data
if import_data_credentials && import_data_credentials['repo'] if defined?(repo_data)
@repo = FogbugzImport::Repository.new(repo_data) @repo = FogbugzImport::Repository.new(repo_data)
@known_labels = Set.new @known_labels = Set.new
else else
...@@ -18,10 +18,8 @@ module Gitlab ...@@ -18,10 +18,8 @@ module Gitlab
def execute def execute
return true unless repo.valid? return true unless repo.valid?
Rails.logger.error import_data_credentials.inspect
data = project.import_data.try(:data) client = Gitlab::FogbugzImport::Client.new(token: import_data_credentials['fb_session']['token'], uri: import_data_credentials['fb_session']['uri'])
client = Gitlab::FogbugzImport::Client.new(token: data['fb_session']['token'], uri: data['fb_session']['uri'])
@cases = client.cases(@repo.id.to_i) @cases = client.cases(@repo.id.to_i)
@categories = client.categories @categories = client.categories
...@@ -34,7 +32,7 @@ module Gitlab ...@@ -34,7 +32,7 @@ module Gitlab
private private
def import_data_credentials def import_data_credentials
@import_data_credentials ||= project.import_data.credentials if project.import_data @import_data_credentials ||= project.import_data.stringified_credentials if project.import_data
end end
def user_map def user_map
...@@ -244,8 +242,8 @@ module Gitlab ...@@ -244,8 +242,8 @@ module Gitlab
def build_attachment_url(rel_url) def build_attachment_url(rel_url)
data = project.import_data.try(:data) data = project.import_data.try(:data)
uri = data['fb_session']['uri'] uri = import_data_credentials['fb_session']['uri']
token = data['fb_session']['token'] token = import_data_credentials['fb_session']['token']
"#{uri}/#{rel_url}&token=#{token}" "#{uri}/#{rel_url}&token=#{token}"
end end
......
...@@ -25,9 +25,10 @@ module Gitlab ...@@ -25,9 +25,10 @@ module Gitlab
).execute ).execute
import_data = project.import_data import_data = project.import_data
import_data.data = { 'repo' => repo.raw_data, 'user_map' => user_map }
# merge! with a bang doesn't work here # merge! with a bang doesn't work here
import_data.credentials = import_data.credentials.merge('fb_session' => fb_session) import_data.credentials = import_data.credentials.merge('fb_session' => fb_session)
import_data.data = { 'repo' => repo.raw_data, 'user_map' => user_map }
import_data.save import_data.save
project project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment