Use Projects::CreateService to create imported projects so hooks are executed.
This commit is contained in:
parent
e69e430ce7
commit
99abbe7dbe
4 changed files with 12 additions and 64 deletions
|
@ -10,29 +10,16 @@ module Gitlab
|
|||
end
|
||||
|
||||
def execute
|
||||
@project = Project.new(
|
||||
::Projects::CreateService.new(current_user,
|
||||
name: repo["name"],
|
||||
path: repo["slug"],
|
||||
description: repo["description"],
|
||||
namespace: namespace,
|
||||
creator: current_user,
|
||||
namespace_id: namespace.id,
|
||||
visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
|
||||
import_type: "bitbucket",
|
||||
import_source: "#{repo["owner"]}/#{repo["slug"]}",
|
||||
import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git"
|
||||
)
|
||||
|
||||
if @project.save!
|
||||
@project.reload
|
||||
|
||||
if @project.import_failed?
|
||||
@project.import_retry
|
||||
else
|
||||
@project.import_start
|
||||
end
|
||||
end
|
||||
|
||||
@project
|
||||
).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,29 +10,16 @@ module Gitlab
|
|||
end
|
||||
|
||||
def execute
|
||||
@project = Project.new(
|
||||
::Projects::CreateService.new(current_user,
|
||||
name: repo.name,
|
||||
path: repo.name,
|
||||
description: repo.description,
|
||||
namespace: namespace,
|
||||
creator: current_user,
|
||||
namespace_id: namespace.id,
|
||||
visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC,
|
||||
import_type: "github",
|
||||
import_source: repo.full_name,
|
||||
import_url: repo.clone_url.sub("https://", "https://#{current_user.github_access_token}@")
|
||||
)
|
||||
|
||||
if @project.save!
|
||||
@project.reload
|
||||
|
||||
if @project.import_failed?
|
||||
@project.import_retry
|
||||
else
|
||||
@project.import_start
|
||||
end
|
||||
end
|
||||
|
||||
@project
|
||||
).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,29 +10,16 @@ module Gitlab
|
|||
end
|
||||
|
||||
def execute
|
||||
@project = Project.new(
|
||||
::Projects::CreateService.new(current_user,
|
||||
name: repo["name"],
|
||||
path: repo["path"],
|
||||
description: repo["description"],
|
||||
namespace: namespace,
|
||||
creator: current_user,
|
||||
namespace_id: namespace.id,
|
||||
visibility_level: repo["visibility_level"],
|
||||
import_type: "gitlab",
|
||||
import_source: repo["path_with_namespace"],
|
||||
import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{current_user.gitlab_access_token}@")
|
||||
)
|
||||
|
||||
if @project.save!
|
||||
@project.reload
|
||||
|
||||
if @project.import_failed?
|
||||
@project.import_retry
|
||||
else
|
||||
@project.import_start
|
||||
end
|
||||
end
|
||||
|
||||
@project
|
||||
).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,29 +10,16 @@ module Gitlab
|
|||
end
|
||||
|
||||
def execute
|
||||
@project = Project.new(
|
||||
::Projects::CreateService.new(current_user,
|
||||
name: repo.name,
|
||||
path: repo.path,
|
||||
description: repo.description,
|
||||
namespace: namespace,
|
||||
creator: current_user,
|
||||
namespace_id: namespace.id,
|
||||
visibility_level: Gitlab::VisibilityLevel::PUBLIC,
|
||||
import_type: "gitorious",
|
||||
import_source: repo.full_name,
|
||||
import_url: repo.import_url
|
||||
)
|
||||
|
||||
if @project.save!
|
||||
@project.reload
|
||||
|
||||
if @project.import_failed?
|
||||
@project.import_retry
|
||||
else
|
||||
@project.import_start
|
||||
end
|
||||
end
|
||||
|
||||
@project
|
||||
).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue