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

38 lines
960 B
Ruby
Raw Normal View History

2015-02-17 10:59:50 -05:00
module Gitlab
module BitbucketImport
class ProjectCreator
attr_reader :repo, :name, :namespace, :current_user, :session_data
2015-02-17 10:59:50 -05:00
def initialize(repo, name, namespace, current_user, session_data)
2015-02-17 10:59:50 -05:00
@repo = repo
@name = name
2015-02-17 10:59:50 -05:00
@namespace = namespace
@current_user = current_user
@session_data = session_data
2015-02-17 10:59:50 -05:00
end
def execute
2016-05-10 05:10:51 -04:00
::Projects::CreateService.new(
2015-12-14 21:53:52 -05: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 13:44:57 -05:00
import_data: { credentials: session_data },
skip_wiki: skip_wiki
).execute
2015-02-17 10:59:50 -05:00
end
2016-12-19 13:44:57 -05:00
private
def skip_wiki
repo.has_wiki?
end
2015-02-17 10:59:50 -05:00
end
end
end