2015-02-17 15:59:50 +00:00
|
|
|
module Gitlab
|
|
|
|
module BitbucketImport
|
|
|
|
class ProjectCreator
|
2015-08-07 07:06:20 +00:00
|
|
|
attr_reader :repo, :namespace, :current_user, :session_data
|
2015-02-17 15:59:50 +00:00
|
|
|
|
2015-08-07 07:06:20 +00:00
|
|
|
def initialize(repo, namespace, current_user, session_data)
|
2015-02-17 15:59:50 +00:00
|
|
|
@repo = repo
|
|
|
|
@namespace = namespace
|
|
|
|
@current_user = current_user
|
2015-08-07 07:06:20 +00:00
|
|
|
@session_data = session_data
|
2015-02-17 15:59:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2015-12-15 02:53:52 +00:00
|
|
|
project = ::Projects::CreateService.new(
|
|
|
|
current_user,
|
2015-02-17 15:59:50 +00:00
|
|
|
name: repo["name"],
|
|
|
|
path: repo["slug"],
|
|
|
|
description: repo["description"],
|
2015-04-06 12:51:09 +00:00
|
|
|
namespace_id: namespace.id,
|
2015-02-17 15:59:50 +00:00
|
|
|
visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
|
|
|
|
import_type: "bitbucket",
|
|
|
|
import_source: "#{repo["owner"]}/#{repo["slug"]}",
|
2015-08-07 07:06:20 +00:00
|
|
|
import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git",
|
2015-04-06 12:51:09 +00:00
|
|
|
).execute
|
2016-03-29 14:10:35 +00:00
|
|
|
|
2016-04-07 13:00:20 +00:00
|
|
|
project.update_import_data(credentials: { bb_session: session_data })
|
2016-03-29 14:10:35 +00:00
|
|
|
|
2015-08-07 07:06:20 +00:00
|
|
|
project
|
2015-02-17 15:59:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|