diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
commit | 3fbd6ba74ee268ad739599ae14dcf5c9b6acfc2c (patch) | |
tree | eea3db86df012fd59b4db8c4ec132e494bdac8fb /app/services/import | |
parent | d41edc2e93480db35e48ad770ebe95075fbca871 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/import')
-rw-r--r-- | app/services/import/github_service.rb | 14 |
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', |