gitlab-org--gitlab-foss/lib/gitlab/bitbucket_import/project_creator.rb

33 lines
1019 B
Ruby
Raw Normal View History

2015-02-17 15:59:50 +00:00
module Gitlab
module BitbucketImport
class ProjectCreator
attr_reader :repo, :namespace, :current_user, :session_data
2015-02-17 15:59:50 +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
@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"],
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"]}",
import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git",
).execute
project.create_or_update_import_data(credentials: { bb_session: session_data })
project
2015-02-17 15:59:50 +00:00
end
end
end
end