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

38 lines
960 B
Ruby
Raw Normal View History

2015-02-17 15:59:50 +00:00
module Gitlab
module BitbucketImport
class ProjectCreator
attr_reader :repo, :name, :namespace, :current_user, :session_data
2015-02-17 15:59:50 +00:00
def initialize(repo, name, namespace, current_user, session_data)
2015-02-17 15:59:50 +00:00
@repo = repo
@name = name
2015-02-17 15:59:50 +00:00
@namespace = namespace
@current_user = current_user
@session_data = session_data
2015-02-17 15:59:50 +00:00
end
def execute
2016-05-10 09:10:51 +00:00
::Projects::CreateService.new(
2015-12-15 02:53:52 +00:00
current_user,
name: name,
path: name,
description: repo.description,
namespace_id: namespace.id,
visibility_level: repo.visibility_level,
import_type: 'bitbucket',
import_source: repo.full_name,
import_url: repo.clone_url(session_data[:token]),
2016-12-19 18:44:57 +00:00
import_data: { credentials: session_data },
skip_wiki: skip_wiki
).execute
2015-02-17 15:59:50 +00:00
end
2016-12-19 18:44:57 +00:00
private
def skip_wiki
repo.has_wiki?
end
2015-02-17 15:59:50 +00:00
end
end
end