Commit 64c39055 authored by James Lopez's avatar James Lopez Committed by Robert Speicher

some refactoring and fixing spec

parent b2b3e0e6
...@@ -1017,4 +1017,9 @@ class Project < ActiveRecord::Base ...@@ -1017,4 +1017,9 @@ class Project < ActiveRecord::Base
builds.running_or_pending.count(:all) builds.running_or_pending.count(:all)
end end
end end
def mark_import_as_failed(error_message)
import_fail
update_column(:import_error, Gitlab::UrlSanitizer.sanitize(error_message))
end
end end
...@@ -15,8 +15,7 @@ class RepositoryForkWorker ...@@ -15,8 +15,7 @@ class RepositoryForkWorker
result = gitlab_shell.fork_repository(source_path, target_path) result = gitlab_shell.fork_repository(source_path, target_path)
unless result unless result
logger.error("Unable to fork project #{project_id} for repository #{source_path} -> #{target_path}") logger.error("Unable to fork project #{project_id} for repository #{source_path} -> #{target_path}")
project.update(import_error: "The project could not be forked.") project.mark_import_as_failed('The project could not be forked.')
project.import_fail
return return
end end
...@@ -24,8 +23,7 @@ class RepositoryForkWorker ...@@ -24,8 +23,7 @@ class RepositoryForkWorker
unless project.valid_repo? unless project.valid_repo?
logger.error("Project #{project_id} had an invalid repository after fork") logger.error("Project #{project_id} had an invalid repository after fork")
project.update(import_error: "The forked repository is invalid.") project.mark_import_as_failed('The forked repository is invalid.')
project.import_fail
return return
end end
......
...@@ -13,8 +13,7 @@ class RepositoryImportWorker ...@@ -13,8 +13,7 @@ class RepositoryImportWorker
result = Projects::ImportService.new(project, current_user).execute result = Projects::ImportService.new(project, current_user).execute
if result[:status] == :error if result[:status] == :error
project.update(import_error: Gitlab::UrlSanitizer.sanitize(result[:message])) project.mark_import_as_failed(Gitlab::UrlSanitizer.sanitize(result[:message]))
project.import_fail
return return
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment