BigW Consortium Gitlab

project_creator.rb 960 Bytes
Newer Older
Douwe Maan committed
1 2 3
module Gitlab
  module BitbucketImport
    class ProjectCreator
4
      attr_reader :repo, :name, :namespace, :current_user, :session_data
Douwe Maan committed
5

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

      def execute
15
        ::Projects::CreateService.new(
16
          current_user,
17 18
          name: name,
          path: name,
19
          description: repo.description,
20
          namespace_id: namespace.id,
21 22 23
          visibility_level: repo.visibility_level,
          import_type: 'bitbucket',
          import_source: repo.full_name,
24
          import_url: repo.clone_url(session_data[:token]),
25 26
          import_data: { credentials: session_data },
          skip_wiki: skip_wiki
27
        ).execute
Douwe Maan committed
28
      end
29 30 31 32 33 34

      private

      def skip_wiki
        repo.has_wiki?
      end
Douwe Maan committed
35 36 37
    end
  end
end