summaryrefslogtreecommitdiff
path: root/app/workers/concerns/gitlab/github_import/object_importer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/concerns/gitlab/github_import/object_importer.rb')
-rw-r--r--app/workers/concerns/gitlab/github_import/object_importer.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb
index c2cd50d8c21..9793278ac0c 100644
--- a/app/workers/concerns/gitlab/github_import/object_importer.rb
+++ b/app/workers/concerns/gitlab/github_import/object_importer.rb
@@ -37,27 +37,22 @@ module Gitlab
importer_class.new(object, project, client).execute
- Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :imported)
+ if increment_object_counter?(object)
+ Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :imported)
+ end
info(project.id, message: 'importer finished')
rescue NoMethodError => e
# This exception will be more useful in development when a new
# Representation is created but the developer forgot to add a
# `:github_identifiers` field.
- Gitlab::Import::ImportFailureService.track(
- project_id: project.id,
- error_source: importer_class.name,
- exception: e,
- fail_import: true
- )
-
- raise(e)
+ track_and_raise_exception(project, e, fail_import: true)
rescue StandardError => e
- Gitlab::Import::ImportFailureService.track(
- project_id: project.id,
- error_source: importer_class.name,
- exception: e
- )
+ track_and_raise_exception(project, e)
+ end
+
+ def increment_object_counter?(_object)
+ true
end
def object_type
@@ -90,6 +85,17 @@ module Gitlab
github_identifiers: github_identifiers
)
end
+
+ def track_and_raise_exception(project, exception, fail_import: false)
+ Gitlab::Import::ImportFailureService.track(
+ project_id: project.id,
+ error_source: importer_class.name,
+ exception: exception,
+ fail_import: fail_import
+ )
+
+ raise(exception)
+ end
end
end
end