Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-03 13:28:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-03 13:28:37 +0300
commit662bb2b6f1f5b5730a0d1eaa66238e718468645d (patch)
treec1ca759e7d2c96e9c2023bbcf946f79e423473a5 /lib
parented8af41027110fdad8f7bb4d53329eb73417fb8d (diff)
Add latest changes from gitlab-org/gitlab@12-5-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/api/projects.rb1
-rw-r--r--lib/gitlab/exception_log_formatter.rb20
-rw-r--r--lib/gitlab/grape_logging/loggers/exception_logger.rb14
-rw-r--r--lib/gitlab/import_export/relation_factory.rb7
-rw-r--r--lib/quality/test_level.rb8
5 files changed, 38 insertions, 12 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 669def2b63c..a1fce9e8b20 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -191,6 +191,7 @@ module API
optional :path, type: String, desc: 'The path of the repository'
optional :default_branch, type: String, desc: 'The default branch of the project'
use :optional_project_params
+ use :optional_create_project_params
use :create_params
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/exception_log_formatter.rb b/lib/gitlab/exception_log_formatter.rb
new file mode 100644
index 00000000000..e0de0219294
--- /dev/null
+++ b/lib/gitlab/exception_log_formatter.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module ExceptionLogFormatter
+ def self.format!(exception, payload)
+ return unless exception
+
+ # Elasticsearch/Fluentd don't handle nested structures well.
+ # Use periods to flatten the fields.
+ payload.merge!(
+ 'exception.class' => exception.class.name,
+ 'exception.message' => exception.message
+ )
+
+ if exception.backtrace
+ payload['exception.backtrace'] = Gitlab::Profiler.clean_backtrace(exception.backtrace)
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/grape_logging/loggers/exception_logger.rb b/lib/gitlab/grape_logging/loggers/exception_logger.rb
index 022eb15d28d..606b7c0dbce 100644
--- a/lib/gitlab/grape_logging/loggers/exception_logger.rb
+++ b/lib/gitlab/grape_logging/loggers/exception_logger.rb
@@ -11,19 +11,11 @@ module Gitlab
# precedence so the logger never sees it. We need to
# store and retrieve the exception from the environment.
exception = request.env[::API::Helpers::API_EXCEPTION_ENV]
+ data = {}
- return {} unless exception.is_a?(Exception)
+ return data unless exception.is_a?(Exception)
- data = {
- exception: {
- class: exception.class.to_s,
- message: exception.message
- }
- }
-
- if exception.backtrace
- data[:exception][:backtrace] = Gitlab::Profiler.clean_backtrace(exception.backtrace)
- end
+ Gitlab::ExceptionLogFormatter.format!(exception, data)
data
end
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index ae6b3c161ce..5d907300d68 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -327,7 +327,12 @@ module Gitlab
end
def find_or_create_object!
- return relation_class.find_or_create_by(project_id: @project.id) if UNIQUE_RELATIONS.include?(@relation_name)
+ if UNIQUE_RELATIONS.include?(@relation_name)
+ unique_relation_object = relation_class.find_or_create_by(project_id: @project.id)
+ unique_relation_object.assign_attributes(parsed_relation_hash)
+
+ return unique_relation_object
+ end
# Can't use IDs as validation exists calling `group` or `project` attributes
finder_hash = parsed_relation_hash.tap do |hash|
diff --git a/lib/quality/test_level.rb b/lib/quality/test_level.rb
index b7822adf6ed..90a8096cc2b 100644
--- a/lib/quality/test_level.rb
+++ b/lib/quality/test_level.rb
@@ -36,6 +36,10 @@ module Quality
workers
elastic_integration
],
+ migration: %w[
+ migrations
+ lib/gitlab/background_migration
+ ],
integration: %w[
controllers
mailers
@@ -62,6 +66,10 @@ module Quality
def level_for(file_path)
case file_path
+ # Detect migration first since some background migration tests are under
+ # spec/lib/gitlab/background_migration and tests under spec/lib are unit by default
+ when regexp(:migration)
+ :migration
when regexp(:unit)
:unit
when regexp(:integration)