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>2021-12-01 21:15:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-01 21:15:19 +0300
commit5fc2d78fb96b0fd50dfb737190fd411033b3c3ab (patch)
tree24cb469e61661c923a1398505b2bb928612f80d4 /lib
parent66629d156e2420269ed53eff3dca0912cfe848e2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities/personal_access_token.rb2
-rw-r--r--lib/banzai/filter/references/reference_cache.rb14
-rw-r--r--lib/bulk_imports/projects/graphql/get_project_query.rb17
-rw-r--r--lib/bulk_imports/projects/graphql/get_repository_query.rb17
-rw-r--r--lib/bulk_imports/projects/graphql/queryable.rb25
-rw-r--r--lib/generators/gitlab/usage_metric_generator.rb4
-rw-r--r--lib/gitlab/anonymous_session.rb6
-rw-r--r--lib/gitlab/database/gitlab_loose_foreign_keys.yml11
-rw-r--r--lib/gitlab/database/gitlab_schemas.yml2
-rw-r--r--lib/gitlab/pagination/offset_pagination.rb10
-rw-r--r--lib/gitlab/redis/multi_store.rb4
11 files changed, 57 insertions, 55 deletions
diff --git a/lib/api/entities/personal_access_token.rb b/lib/api/entities/personal_access_token.rb
index 3846929c903..55764daef9d 100644
--- a/lib/api/entities/personal_access_token.rb
+++ b/lib/api/entities/personal_access_token.rb
@@ -3,7 +3,7 @@
module API
module Entities
class PersonalAccessToken < Grape::Entity
- expose :id, :name, :revoked, :created_at, :scopes, :user_id
+ expose :id, :name, :revoked, :created_at, :scopes, :user_id, :last_used_at
expose :active?, as: :active
expose :expires_at do |personal_access_token|
personal_access_token.expires_at ? personal_access_token.expires_at.strftime("%Y-%m-%d") : nil
diff --git a/lib/banzai/filter/references/reference_cache.rb b/lib/banzai/filter/references/reference_cache.rb
index 259958f1598..c8370d5f9c1 100644
--- a/lib/banzai/filter/references/reference_cache.rb
+++ b/lib/banzai/filter/references/reference_cache.rb
@@ -29,7 +29,7 @@ module Banzai
@references_per_parent[parent_type] ||= begin
refs = Hash.new { |hash, key| hash[key] = Set.new }
- prepare_doc_for_scan(filter.doc).to_enum(:scan, regex).each do
+ prepare_doc_for_scan.to_enum(:scan, regex).each do
parent_path = if parent_type == :project
full_project_path($~[:namespace], $~[:project])
else
@@ -184,14 +184,12 @@ module Banzai
Gitlab::SafeRequestStore["banzai_#{parent_type}_refs".to_sym] ||= {}
end
- def prepare_doc_for_scan(doc)
- html = if Feature.enabled?(:reference_cache_memoization, project, default_enabled: :yaml)
- result[:rendered_html] ||= doc.to_html
- else
- doc.to_html
- end
+ def prepare_doc_for_scan
+ filter.requires_unescaping? ? unescape_html_entities(html_content) : html_content
+ end
- filter.requires_unescaping? ? unescape_html_entities(html) : html
+ def html_content
+ result[:rendered_html] ||= filter.doc.to_html
end
def unescape_html_entities(text)
diff --git a/lib/bulk_imports/projects/graphql/get_project_query.rb b/lib/bulk_imports/projects/graphql/get_project_query.rb
index 2aec496880f..04ac0916bbc 100644
--- a/lib/bulk_imports/projects/graphql/get_project_query.rb
+++ b/lib/bulk_imports/projects/graphql/get_project_query.rb
@@ -4,6 +4,7 @@ module BulkImports
module Projects
module Graphql
module GetProjectQuery
+ extend Queryable
extend self
def to_s
@@ -28,22 +29,6 @@ module BulkImports
}
GRAPHQL
end
-
- def variables(context)
- { full_path: context.entity.source_full_path }
- end
-
- def base_path
- %w[data project]
- end
-
- def data_path
- base_path
- end
-
- def page_info_path
- base_path << 'page_info'
- end
end
end
end
diff --git a/lib/bulk_imports/projects/graphql/get_repository_query.rb b/lib/bulk_imports/projects/graphql/get_repository_query.rb
index d3e377c1175..24efce9e276 100644
--- a/lib/bulk_imports/projects/graphql/get_repository_query.rb
+++ b/lib/bulk_imports/projects/graphql/get_repository_query.rb
@@ -4,6 +4,7 @@ module BulkImports
module Projects
module Graphql
module GetRepositoryQuery
+ extend Queryable
extend self
def to_s
@@ -15,22 +16,6 @@ module BulkImports
}
GRAPHQL
end
-
- def variables(context)
- { full_path: context.entity.source_full_path }
- end
-
- def base_path
- %w[data project]
- end
-
- def data_path
- base_path
- end
-
- def page_info_path
- base_path << 'page_info'
- end
end
end
end
diff --git a/lib/bulk_imports/projects/graphql/queryable.rb b/lib/bulk_imports/projects/graphql/queryable.rb
new file mode 100644
index 00000000000..a897632dff3
--- /dev/null
+++ b/lib/bulk_imports/projects/graphql/queryable.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module BulkImports
+ module Projects
+ module Graphql
+ module Queryable
+ def variables(context)
+ { full_path: context.entity.source_full_path }
+ end
+
+ def base_path
+ %w[data project]
+ end
+
+ def data_path
+ base_path
+ end
+
+ def page_info_path
+ base_path << 'page_info'
+ end
+ end
+ end
+ end
+end
diff --git a/lib/generators/gitlab/usage_metric_generator.rb b/lib/generators/gitlab/usage_metric_generator.rb
index c0fdcf21f20..0656dfbc312 100644
--- a/lib/generators/gitlab/usage_metric_generator.rb
+++ b/lib/generators/gitlab/usage_metric_generator.rb
@@ -5,9 +5,9 @@ require 'rails/generators'
module Gitlab
class UsageMetricGenerator < Rails::Generators::Base
CE_DIR = 'lib/gitlab/usage/metrics/instrumentations'
- EE_DIR = 'ee/lib/ee/gitlab/usage/metrics/instrumentations'
+ EE_DIR = 'ee/lib/gitlab/usage/metrics/instrumentations'
SPEC_CE_DIR = 'spec/lib/gitlab/usage/metrics/instrumentations'
- SPEC_EE_DIR = 'ee/spec/lib/ee/gitlab/usage/metrics/instrumentations'
+ SPEC_EE_DIR = 'ee/spec/lib/gitlab/usage/metrics/instrumentations'
ALLOWED_SUPERCLASSES = {
generic: 'Generic',
diff --git a/lib/gitlab/anonymous_session.rb b/lib/gitlab/anonymous_session.rb
index fc78b64830a..e58240e16b4 100644
--- a/lib/gitlab/anonymous_session.rb
+++ b/lib/gitlab/anonymous_session.rb
@@ -10,9 +10,9 @@ module Gitlab
def count_session_ip
redis_store_class.with do |redis|
- redis.pipelined do
- redis.incr(session_lookup_name)
- redis.expire(session_lookup_name, 24.hours)
+ redis.pipelined do |pipeline|
+ pipeline.incr(session_lookup_name)
+ pipeline.expire(session_lookup_name, 24.hours)
end
end
end
diff --git a/lib/gitlab/database/gitlab_loose_foreign_keys.yml b/lib/gitlab/database/gitlab_loose_foreign_keys.yml
index 430ac785449..907a10d0fa3 100644
--- a/lib/gitlab/database/gitlab_loose_foreign_keys.yml
+++ b/lib/gitlab/database/gitlab_loose_foreign_keys.yml
@@ -18,3 +18,14 @@ clusters_applications_runners:
- table: ci_runners
column: runner_id
on_delete: async_nullify
+ci_namespace_mirrors:
+ - table: namespaces
+ column: namespace_id
+ on_delete: async_delete
+ci_project_mirrors:
+ - table: projects
+ column: project_id
+ on_delete: async_delete
+ - table: namespaces
+ column: namespace_id
+ on_delete: async_delete
diff --git a/lib/gitlab/database/gitlab_schemas.yml b/lib/gitlab/database/gitlab_schemas.yml
index 5695f2f1c14..6733318bfaf 100644
--- a/lib/gitlab/database/gitlab_schemas.yml
+++ b/lib/gitlab/database/gitlab_schemas.yml
@@ -86,6 +86,7 @@ ci_job_token_project_scope_links: :gitlab_ci
ci_job_variables: :gitlab_ci
ci_minutes_additional_packs: :gitlab_ci
ci_namespace_monthly_usages: :gitlab_ci
+ci_namespace_mirrors: :gitlab_ci
ci_pending_builds: :gitlab_ci
ci_pipeline_artifacts: :gitlab_ci
ci_pipeline_chat_data: :gitlab_ci
@@ -97,6 +98,7 @@ ci_pipelines: :gitlab_ci
ci_pipeline_variables: :gitlab_ci
ci_platform_metrics: :gitlab_ci
ci_project_monthly_usages: :gitlab_ci
+ci_project_mirrors: :gitlab_ci
ci_refs: :gitlab_ci
ci_resource_groups: :gitlab_ci
ci_resources: :gitlab_ci
diff --git a/lib/gitlab/pagination/offset_pagination.rb b/lib/gitlab/pagination/offset_pagination.rb
index 7b5013f137b..4f8a6ffb2cc 100644
--- a/lib/gitlab/pagination/offset_pagination.rb
+++ b/lib/gitlab/pagination/offset_pagination.rb
@@ -29,7 +29,7 @@ module Gitlab
return pagination_data unless Feature.enabled?(:api_kaminari_count_with_limit, type: :ops)
limited_total_count = pagination_data.total_count_with_limit
- if limited_total_count > max_limit
+ if limited_total_count > Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT
# The call to `total_count_with_limit` memoizes `@arel` because of a call to `references_eager_loaded_tables?`
# We need to call `reset` because `without_count` relies on `@arel` being unmemoized
pagination_data.reset.without_count
@@ -38,14 +38,6 @@ module Gitlab
end
end
- def max_limit
- if Feature.enabled?(:lower_relation_max_count_limit, type: :ops)
- Kaminari::ActiveRecordRelationMethods::MAX_COUNT_NEW_LOWER_LIMIT
- else
- Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT
- end
- end
-
def needs_pagination?(relation)
return true unless relation.respond_to?(:current_page)
return true if params[:page].present? && relation.current_page != params[:page].to_i
diff --git a/lib/gitlab/redis/multi_store.rb b/lib/gitlab/redis/multi_store.rb
index 2602cb54adb..6616f0d4cec 100644
--- a/lib/gitlab/redis/multi_store.rb
+++ b/lib/gitlab/redis/multi_store.rb
@@ -21,6 +21,8 @@ module Gitlab
FAILED_TO_READ_ERROR_MESSAGE = 'Failed to read from the redis primary_store.'
FAILED_TO_WRITE_ERROR_MESSAGE = 'Failed to write to the redis primary_store.'
+ SKIP_LOG_METHOD_MISSING_FOR_COMMANDS = %i(info).freeze
+
READ_COMMANDS = %i(
get
mget
@@ -109,6 +111,8 @@ module Gitlab
end
def log_method_missing(command_name, *_args)
+ return if SKIP_LOG_METHOD_MISSING_FOR_COMMANDS.include?(command_name)
+
log_error(MethodMissingError.new, command_name)
increment_method_missing_count(command_name)
end