project_creator.rb 913 Bytes
Newer Older
1
2
3
module Gitlab
  module GoogleCodeImport
    class ProjectCreator
Douwe Maan's avatar
Douwe Maan committed
4
      attr_reader :repo, :namespace, :current_user, :user_map
5

Douwe Maan's avatar
Douwe Maan committed
6
      def initialize(repo, namespace, current_user, user_map = nil)
7
8
9
        @repo = repo
        @namespace = namespace
        @current_user = current_user
Douwe Maan's avatar
Douwe Maan committed
10
        @user_map = user_map
11
12
13
      end

      def execute
Gabriel Mazetto's avatar
Gabriel Mazetto committed
14
15
        project = ::Projects::CreateService.new(
          current_user,
16
17
18
19
20
21
22
23
          name: repo.name,
          path: repo.name,
          description: repo.summary,
          namespace: namespace,
          creator: current_user,
          visibility_level: Gitlab::VisibilityLevel::PUBLIC,
          import_type: "google_code",
          import_source: repo.name,
24
25
          import_url: repo.import_url
        ).execute
26

27
        project.create_or_update_import_data(data: { 'repo' => repo.raw_data, 'user_map' => user_map })
28

29
        project
30
31
32
33
      end
    end
  end
end