debian-mirror-gitlab/lib/gitlab/bitbucket_import/project_creator.rb

40 lines
991 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
module Gitlab
module BitbucketImport
class ProjectCreator
2017-08-17 22:00:37 +05:30
attr_reader :repo, :name, :namespace, :current_user, :session_data
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
def initialize(repo, name, namespace, current_user, session_data)
2015-04-26 12:48:37 +05:30
@repo = repo
2017-08-17 22:00:37 +05:30
@name = name
2015-04-26 12:48:37 +05:30
@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,
2017-08-17 22:00:37 +05:30
name: name,
path: name,
description: repo.description,
2015-04-26 12:48:37 +05:30
namespace_id: namespace.id,
2017-08-17 22:00:37 +05:30
visibility_level: repo.visibility_level,
import_type: 'bitbucket',
import_source: repo.full_name,
import_url: repo.clone_url(session_data[:token]),
import_data: { credentials: session_data },
skip_wiki: skip_wiki
2015-04-26 12:48:37 +05:30
).execute
end
2017-08-17 22:00:37 +05:30
private
def skip_wiki
repo.has_wiki?
end
2015-04-26 12:48:37 +05:30
end
end
end