Class: Gitlab::GitlabImport::ProjectCreator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, namespace, current_user, session_data) ⇒ ProjectCreator

Returns a new instance of ProjectCreator.


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

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

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


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

def current_user
  @current_user
end

#namespaceObject (readonly)

Returns the value of attribute namespace


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

def namespace
  @namespace
end

#repoObject (readonly)

Returns the value of attribute repo


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

def repo
  @repo
end

#session_dataObject (readonly)

Returns the value of attribute session_data


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

def session_data
  @session_data
end

Instance Method Details

#executeObject


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

def execute
  ::Projects::CreateService.new(
    current_user,
    name: repo["name"],
    path: repo["path"],
    description: repo["description"],
    namespace_id: namespace.id,
    visibility_level: Gitlab::VisibilityLevel.level_value(repo["visibility"]),
    import_type: "gitlab",
    import_source: repo["path_with_namespace"],
    import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{@session_data[:gitlab_access_token]}@")
  ).execute
end