summaryrefslogtreecommitdiff
path: root/app/services/import/github_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/import/github_service.rb')
-rw-r--r--app/services/import/github_service.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/services/import/github_service.rb b/app/services/import/github_service.rb
index 2378a4b11b1..b30c344723d 100644
--- a/app/services/import/github_service.rb
+++ b/app/services/import/github_service.rb
@@ -46,12 +46,8 @@ module Import
@project_name ||= params[:new_name].presence || repo[:name]
end
- def namespace_path
- @namespace_path ||= params[:target_namespace].presence || current_user.namespace_path
- end
-
def target_namespace
- @target_namespace ||= find_or_create_namespace(namespace_path, current_user.namespace_path)
+ @target_namespace ||= Namespace.find_by_full_path(target_namespace_path)
end
def extra_project_attrs
@@ -104,6 +100,8 @@ module Import
def validate_context
if blocked_url?
log_and_return_error("Invalid URL: #{url}", _("Invalid URL: %{url}") % { url: url }, :bad_request)
+ elsif target_namespace.nil?
+ error(_('Namespace or group to import repository into does not exist.'), :unprocessable_entity)
elsif !authorized?
error(_('This namespace has already been taken. Choose a different one.'), :unprocessable_entity)
elsif oversized?
@@ -111,6 +109,12 @@ module Import
end
end
+ def target_namespace_path
+ raise ArgumentError, 'Target namespace is required' if params[:target_namespace].blank?
+
+ params[:target_namespace]
+ end
+
def log_error(exception)
Gitlab::GithubImport::Logger.error(
message: 'Import failed due to a GitHub error',