2015-04-26 12:48:37 +05:30
|
|
|
module Gitlab
|
|
|
|
module BitbucketImport
|
|
|
|
class ProjectCreator
|
2015-09-25 12:07:36 +05:30
|
|
|
attr_reader :repo, :namespace, :current_user, :session_data
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
def initialize(repo, namespace, current_user, session_data)
|
2015-04-26 12:48:37 +05:30
|
|
|
@repo = repo
|
|
|
|
@namespace = namespace
|
|
|
|
@current_user = current_user
|
2015-09-25 12:07:36 +05:30
|
|
|
@session_data = session_data
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-06-02 11:05:42 +05:30
|
|
|
::Projects::CreateService.new(
|
2015-12-23 02:04:40 +05:30
|
|
|
current_user,
|
2015-04-26 12:48:37 +05:30
|
|
|
name: repo["name"],
|
|
|
|
path: repo["slug"],
|
|
|
|
description: repo["description"],
|
|
|
|
namespace_id: namespace.id,
|
|
|
|
visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
|
|
|
|
import_type: "bitbucket",
|
|
|
|
import_source: "#{repo["owner"]}/#{repo["slug"]}",
|
2015-09-25 12:07:36 +05:30
|
|
|
import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git",
|
2016-06-02 11:05:42 +05:30
|
|
|
import_data: { credentials: { bb_session: session_data } }
|
2015-04-26 12:48:37 +05:30
|
|
|
).execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|