diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-03 13:10:01 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-03 13:10:01 +0200 |
commit | 0a51c954641c99610e9eddd9323398fb00d273e2 (patch) | |
tree | ce0e58fcec98f566d7c96af3234da1a8b644c267 /app/services | |
parent | 3577b57f6b03a0d3c3d32daab6dc6ccf5f6e45f7 (diff) | |
parent | 3f4ac2ff60c9d83ec65b19070e4d054e12e67dd2 (diff) | |
download | gitlab-ce-0a51c954641c99610e9eddd9323398fb00d273e2.tar.gz |
Merge remote-tracking branch 'origin/master' into rename-ci-commit
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/create_service.rb | 26 | ||||
-rw-r--r-- | app/services/projects/import_service.rb | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 6728fabea1e..61cac5419ad 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -56,14 +56,14 @@ module Projects after_create_actions if @project.persisted? - @project.add_import_job if @project.import? - + if @project.errors.empty? + @project.add_import_job if @project.import? + else + fail(error: @project.errors.full_messages.join(', ')) + end @project rescue => e - message = "Unable to save project: #{e.message}" - Rails.logger.error(message) - @project.errors.add(:base, message) if @project - @project + fail(error: e.message) end protected @@ -103,5 +103,19 @@ module Projects end end end + + def fail(error:) + message = "Unable to save project. Error: #{error}" + message << "Project ID: #{@project.id}" if @project && @project.id + + Rails.logger.error(message) + + if @project && @project.import? + @project.errors.add(:base, message) + @project.mark_import_as_failed(message) + end + + @project + end end end diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb index ef15ef6a473..c4838d31f2f 100644 --- a/app/services/projects/import_service.rb +++ b/app/services/projects/import_service.rb @@ -39,7 +39,7 @@ module Projects begin gitlab_shell.import_repository(project.path_with_namespace, project.import_url) rescue Gitlab::Shell::Error => e - raise Error, e.message + raise Error, "Error importing repository #{project.import_url} into #{project.path_with_namespace} - #{e.message}" end end |