diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/services/import | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/services/import')
-rw-r--r-- | app/services/import/github_service.rb | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/app/services/import/github_service.rb b/app/services/import/github_service.rb index 3c57fada677..0cf17568c78 100644 --- a/app/services/import/github_service.rb +++ b/app/services/import/github_service.rb @@ -10,15 +10,26 @@ module Import return error(_('This namespace has already been taken! Please choose another one.'), :unprocessable_entity) end - project = Gitlab::LegacyGithubImport::ProjectCreator - .new(repo, project_name, target_namespace, current_user, access_params, type: provider) - .execute(extra_project_attrs) + project = create_project(access_params, provider) if project.persisted? success(project) else error(project_save_error(project), :unprocessable_entity) end + rescue Octokit::Error => e + log_error(e) + end + + def create_project(access_params, provider) + Gitlab::LegacyGithubImport::ProjectCreator.new( + repo, + project_name, + target_namespace, + current_user, + access_params, + type: provider + ).execute(extra_project_attrs) end def repo @@ -44,6 +55,18 @@ module Import def authorized? can?(current_user, :create_projects, target_namespace) end + + private + + def log_error(exception) + Gitlab::Import::Logger.error( + message: 'Import failed due to a GitHub error', + status: exception.response_status, + error: exception.response_body + ) + + error(_('Import failed due to a GitHub error: %{original}') % { original: exception.response_body }, :unprocessable_entity) + end end end |