summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-06 14:51:09 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-06 14:51:09 +0200
commit99abbe7dbe5dfbeba5869ffa35cac2b36cd5578c (patch)
treeaf9d77bd79885de3682e757c22f52ebb83ead4cc
parente69e430ce70a0a679214669437c7521611e4b77c (diff)
downloadgitlab-ce-99abbe7dbe5dfbeba5869ffa35cac2b36cd5578c.tar.gz
Use Projects::CreateService to create imported projects so hooks are executed.
-rw-r--r--lib/gitlab/bitbucket_import/project_creator.rb19
-rw-r--r--lib/gitlab/github_import/project_creator.rb19
-rw-r--r--lib/gitlab/gitlab_import/project_creator.rb19
-rw-r--r--lib/gitlab/gitorious_import/project_creator.rb19
4 files changed, 12 insertions, 64 deletions
diff --git a/lib/gitlab/bitbucket_import/project_creator.rb b/lib/gitlab/bitbucket_import/project_creator.rb
index db33af2c2da..54420e62c90 100644
--- a/lib/gitlab/bitbucket_import/project_creator.rb
+++ b/lib/gitlab/bitbucket_import/project_creator.rb
@@ -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
diff --git a/lib/gitlab/github_import/project_creator.rb b/lib/gitlab/github_import/project_creator.rb
index 9439ca6cbf4..2723eec933e 100644
--- a/lib/gitlab/github_import/project_creator.rb
+++ b/lib/gitlab/github_import/project_creator.rb
@@ -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
diff --git a/lib/gitlab/gitlab_import/project_creator.rb b/lib/gitlab/gitlab_import/project_creator.rb
index 6424d56f8f1..f0d7141bf56 100644
--- a/lib/gitlab/gitlab_import/project_creator.rb
+++ b/lib/gitlab/gitlab_import/project_creator.rb
@@ -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
diff --git a/lib/gitlab/gitorious_import/project_creator.rb b/lib/gitlab/gitorious_import/project_creator.rb
index 3cbebe53997..cc9a91c91f4 100644
--- a/lib/gitlab/gitorious_import/project_creator.rb
+++ b/lib/gitlab/gitorious_import/project_creator.rb
@@ -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