2018-10-11 16:12:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-17 10:59:50 -05:00
|
|
|
module Gitlab
|
|
|
|
module BitbucketImport
|
|
|
|
class ProjectCreator
|
2016-11-11 19:07:16 -05:00
|
|
|
attr_reader :repo, :name, :namespace, :current_user, :session_data
|
2015-02-17 10:59:50 -05:00
|
|
|
|
2016-11-11 19:07:16 -05:00
|
|
|
def initialize(repo, name, namespace, current_user, session_data)
|
2015-02-17 10:59:50 -05:00
|
|
|
@repo = repo
|
2016-11-11 19:07:16 -05:00
|
|
|
@name = name
|
2015-02-17 10:59:50 -05:00
|
|
|
@namespace = namespace
|
|
|
|
@current_user = current_user
|
2015-08-07 03:06:20 -04:00
|
|
|
@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,
|
2016-11-11 19:07:16 -05:00
|
|
|
name: name,
|
|
|
|
path: name,
|
2016-08-22 15:04:11 -04:00
|
|
|
description: repo.description,
|
2015-04-06 08:51:09 -04:00
|
|
|
namespace_id: namespace.id,
|
2016-08-22 15:04:11 -04:00
|
|
|
visibility_level: repo.visibility_level,
|
|
|
|
import_type: 'bitbucket',
|
|
|
|
import_source: repo.full_name,
|
2016-12-15 07:19:28 -05:00
|
|
|
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
|
2015-04-06 08:51:09 -04:00
|
|
|
).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
|