Class: Gitlab::ManifestImport::ProjectCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/manifest_import/project_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, destination, current_user) ⇒ ProjectCreator

Returns a new instance of ProjectCreator.



8
9
10
11
12
# File 'lib/gitlab/manifest_import/project_creator.rb', line 8

def initialize(repository, destination, current_user)
  @repository = repository
  @destination = destination
  @current_user = current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'lib/gitlab/manifest_import/project_creator.rb', line 6

def current_user
  @current_user
end

#destinationObject (readonly)

Returns the value of attribute destination.



6
7
8
# File 'lib/gitlab/manifest_import/project_creator.rb', line 6

def destination
  @destination
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'lib/gitlab/manifest_import/project_creator.rb', line 6

def repository
  @repository
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/manifest_import/project_creator.rb', line 14

def execute
  group_full_path, _, project_path = repository[:path].rpartition('/')
  group_full_path = File.join(destination.full_path, group_full_path) if destination
  group = create_group_with_parents(group_full_path)

  params = {
    import_url: repository[:url],
    import_source: repository[:url],
    import_type: 'manifest',
    namespace_id: group.id,
    path: project_path,
    name: project_path,
    visibility_level: destination.visibility_level
  }

  Projects::CreateService.new(current_user, params).execute
end