BigW Consortium Gitlab

project_creator.rb 852 Bytes
Newer Older
1 2 3
module Gitlab
  module GitlabImport
    class ProjectCreator
4
      attr_reader :repo, :namespace, :current_user, :session_data
5

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

      def execute
14
        ::Projects::CreateService.new(
15
          current_user,
16 17 18 19 20 21 22 23
          name: repo["name"],
          path: repo["path"],
          description: repo["description"],
          namespace_id: namespace.id,
          visibility_level: repo["visibility_level"],
          import_type: "gitlab",
          import_source: repo["path_with_namespace"],
          import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{@session_data[:gitlab_access_token]}@")
24
        ).execute
25 26 27 28
      end
    end
  end
end