summaryrefslogtreecommitdiff
path: root/lib/gitlab/bitbucket_import/project_creator.rb
blob: b34be272af387a8b022b9f04e5b4aea78ded97db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Gitlab
  module BitbucketImport
    class ProjectCreator
      attr_reader :repo, :name, :namespace, :current_user, :session_data

      def initialize(repo, name, namespace, current_user, session_data)
        @repo = repo
        @name = name
        @namespace = namespace
        @current_user = current_user
        @session_data = session_data
      end

      def execute
        ::Projects::CreateService.new(
          current_user,
          name: name,
          path: name,
          description: repo.description,
          namespace_id: namespace.id,
          visibility_level: repo.visibility_level,
          import_type: 'bitbucket',
          import_source: repo.full_name,
          import_url: repo.clone_url(@session_data[:token]),
          import_data: { credentials: session_data }
        ).execute
      end
    end
  end
end