BigW Consortium Gitlab

project_creator.rb 962 Bytes
Newer Older
Valery Sizov committed
1
module Gitlab
2
  module GithubImport
Valery Sizov committed
3
    class ProjectCreator
4
      attr_reader :repo, :namespace, :current_user, :session_data
Valery Sizov committed
5

6
      def initialize(repo, namespace, current_user, session_data)
Valery Sizov committed
7 8 9
        @repo = repo
        @namespace = namespace
        @current_user = current_user
10
        @session_data = session_data
Valery Sizov committed
11 12 13
      end

      def execute
14
        ::Projects::CreateService.new(
15
          current_user,
Valery Sizov committed
16 17 18
          name: repo.name,
          path: repo.name,
          description: repo.description,
19
          namespace_id: namespace.id,
Valery Sizov committed
20 21 22
          visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
          import_type: "github",
          import_source: repo.full_name,
23
          import_url: repo.clone_url.sub("https://", "https://#{@session_data[:github_access_token]}@"),
24
          wiki_enabled: !repo.has_wiki? # If repo has wiki we'll import it later
25
        ).execute
26
      end
Valery Sizov committed
27 28 29
    end
  end
end