summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-31 11:00:59 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-06-02 21:48:25 -0400
commit64c3905523808942ac62b7ebfbce3634b6e9dc17 (patch)
tree013a6787017c046c5beaf90bbb5e1ea3db3648e0 /app
parentb2b3e0e6ee8e428322ae6aff172b59e040750ae0 (diff)
downloadgitlab-ce-64c3905523808942ac62b7ebfbce3634b6e9dc17.tar.gz
some refactoring and fixing spec
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb5
-rw-r--r--app/workers/repository_fork_worker.rb6
-rw-r--r--app/workers/repository_import_worker.rb3
3 files changed, 8 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 9ccf6a97df6..03429fb7a46 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1017,4 +1017,9 @@ class Project < ActiveRecord::Base
builds.running_or_pending.count(:all)
end
end
+
+ def mark_import_as_failed(error_message)
+ import_fail
+ update_column(:import_error, Gitlab::UrlSanitizer.sanitize(error_message))
+ end
end
diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb
index f9e32337983..d947f105516 100644
--- a/app/workers/repository_fork_worker.rb
+++ b/app/workers/repository_fork_worker.rb
@@ -15,8 +15,7 @@ class RepositoryForkWorker
result = gitlab_shell.fork_repository(source_path, target_path)
unless result
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.import_fail
+ project.mark_import_as_failed('The project could not be forked.')
return
end
@@ -24,8 +23,7 @@ class RepositoryForkWorker
unless project.valid_repo?
logger.error("Project #{project_id} had an invalid repository after fork")
- project.update(import_error: "The forked repository is invalid.")
- project.import_fail
+ project.mark_import_as_failed('The forked repository is invalid.')
return
end
diff --git a/app/workers/repository_import_worker.rb b/app/workers/repository_import_worker.rb
index fbc7ed63c6a..56411bca572 100644
--- a/app/workers/repository_import_worker.rb
+++ b/app/workers/repository_import_worker.rb
@@ -13,8 +13,7 @@ class RepositoryImportWorker
result = Projects::ImportService.new(project, current_user).execute
if result[:status] == :error
- project.update(import_error: Gitlab::UrlSanitizer.sanitize(result[:message]))
- project.import_fail
+ project.mark_import_as_failed(Gitlab::UrlSanitizer.sanitize(result[:message]))
return
end