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

33 lines
1 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
module Gitlab
module GithubImport
class ProjectCreator
2015-09-25 12:07:36 +05:30
attr_reader :repo, :namespace, :current_user, :session_data
2015-04-26 12:48:37 +05:30
2015-09-25 12:07:36 +05:30
def initialize(repo, namespace, current_user, session_data)
2015-04-26 12:48:37 +05:30
@repo = repo
@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
2015-09-25 12:07:36 +05:30
project = ::Projects::CreateService.new(
current_user,
2015-04-26 12:48:37 +05:30
name: repo.name,
path: repo.name,
description: repo.description,
namespace_id: namespace.id,
visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
import_type: "github",
import_source: repo.full_name,
import_url: repo.clone_url.sub("https://", "https://#{@session_data[:github_access_token]}@"),
wiki_enabled: !repo.has_wiki? # If repo has wiki we'll import it later
2015-04-26 12:48:37 +05:30
).execute
2015-09-25 12:07:36 +05:30
project.create_import_data(data: { "github_session" => session_data } )
project
2015-04-26 12:48:37 +05:30
end
end
end
end