diff options
| author | Douwe Maan <douwe@gitlab.com> | 2018-10-16 22:39:33 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2018-10-16 22:39:33 +0000 |
| commit | a706b3735ef01072401dd1ee67ba0586a2fdf61c (patch) | |
| tree | cd16c664e7c0a207c8a2cc7ff0c97d6e5c619b92 /lib | |
| parent | 90056ed25b547537b02b29715e6153d3aab4cc79 (diff) | |
| parent | 68eafa50e925ac6da60d84a67884c53c13552315 (diff) | |
| download | gitlab-ce-a706b3735ef01072401dd1ee67ba0586a2fdf61c.tar.gz | |
Merge branch 'master' into 'dm-document-role-maintainer'
# Conflicts:
# doc/development/code_review.md
Diffstat (limited to 'lib')
138 files changed, 471 insertions, 851 deletions
diff --git a/lib/api/circuit_breakers.rb b/lib/api/circuit_breakers.rb index 6eddc5e5b61..da756daadcc 100644 --- a/lib/api/circuit_breakers.rb +++ b/lib/api/circuit_breakers.rb @@ -13,37 +13,24 @@ module API end resource ':type' do namespace '', requirements: { type: 'repository_storage' } do - helpers do - def failing_storage_health - @failing_storage_health ||= Gitlab::Git::Storage::Health.for_failing_storages - end - - def storage_health - @storage_health ||= Gitlab::Git::Storage::Health.for_all_storages - end - end - desc 'Get all git storages' do detail 'This feature was introduced in GitLab 9.5' - success Entities::RepositoryStorageHealth end get do - present storage_health, with: Entities::RepositoryStorageHealth + present [] end desc 'Get all failing git storages' do detail 'This feature was introduced in GitLab 9.5' - success Entities::RepositoryStorageHealth end get 'failing' do - present failing_storage_health, with: Entities::RepositoryStorageHealth + present [] end desc 'Reset all storage failures and open circuitbreaker' do detail 'This feature was introduced in GitLab 9.5' end delete do - Gitlab::Git::Storage::FailureInfo.reset_all! end end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 120545792f2..5a4b85f98cf 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1364,12 +1364,6 @@ module API expose :submitted, as: :akismet_submitted end - class RepositoryStorageHealth < Grape::Entity - expose :storage_name - expose :failing_on_hosts - expose :total_failures - end - class CustomAttribute < Grape::Entity expose :key expose :value diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 5125f302fbb..dc844c0bd27 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -130,18 +130,13 @@ module API success Entities::Commit end params do - # For now we just support 2 refs passed, but `merge-base` supports - # multiple defining this as an Array instead of 2 separate params will - # make sure we don't need to deprecate this API in favor of one - # supporting multiple commits when this functionality gets added to - # Gitaly requires :refs, type: Array[String] end get ':id/repository/merge_base' do refs = params[:refs] - unless refs.size == 2 - render_api_error!('Provide exactly 2 refs', 400) + if refs.size < 2 + render_api_error!('Provide at least 2 refs', 400) end merge_base = Gitlab::Git::MergeBase.new(user_project.repository, refs) diff --git a/lib/api/settings.rb b/lib/api/settings.rb index edbd134822c..f53ba0ab761 100644 --- a/lib/api/settings.rb +++ b/lib/api/settings.rb @@ -66,10 +66,6 @@ module API optional :html_emails_enabled, type: Boolean, desc: 'By default GitLab sends emails in HTML and plain text formats so mail clients can choose what format to use. Disable this option if you only want to send emails in plain text format.' optional :import_sources, type: Array[String], values: %w[github bitbucket gitlab google_code fogbugz git gitlab_project manifest], desc: 'Enabled sources for code import during project creation. OmniAuth must be configured for GitHub, Bitbucket, and GitLab.com' - optional :koding_enabled, type: Boolean, desc: 'Enable Koding' - given koding_enabled: ->(val) { val } do - requires :koding_url, type: String, desc: 'The Koding team URL' - end optional :max_artifacts_size, type: Integer, desc: "Set the maximum file size for each job's artifacts" optional :max_attachment_size, type: Integer, desc: 'Maximum attachment size in MB' optional :max_pages_size, type: Integer, desc: 'Maximum size of pages in MB' diff --git a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb index 91175b49c79..15cdd25e711 100644 --- a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb +++ b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators' module Rails diff --git a/lib/gitaly/server.rb b/lib/gitaly/server.rb index f95e423ef22..7b238623418 100644 --- a/lib/gitaly/server.rb +++ b/lib/gitaly/server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitaly class Server def self.all diff --git a/lib/gitlab/auth/activity.rb b/lib/gitlab/auth/activity.rb index 761f0819c60..558628b5422 100644 --- a/lib/gitlab/auth/activity.rb +++ b/lib/gitlab/auth/activity.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth ## diff --git a/lib/gitlab/auth/database/authentication.rb b/lib/gitlab/auth/database/authentication.rb index 1234ace0334..c0dc2b0875f 100644 --- a/lib/gitlab/auth/database/authentication.rb +++ b/lib/gitlab/auth/database/authentication.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # These calls help to authenticate to OAuth provider by providing username and password # diff --git a/lib/gitlab/auth/ip_rate_limiter.rb b/lib/gitlab/auth/ip_rate_limiter.rb index e6173d45af3..81e616fa20a 100644 --- a/lib/gitlab/auth/ip_rate_limiter.rb +++ b/lib/gitlab/auth/ip_rate_limiter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth class IpRateLimiter diff --git a/lib/gitlab/auth/ldap/access.rb b/lib/gitlab/auth/ldap/access.rb index f323d2e0f7a..c875bba4bcb 100644 --- a/lib/gitlab/auth/ldap/access.rb +++ b/lib/gitlab/auth/ldap/access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # LDAP authorization model # # * Check if we are allowed access (not blocked) diff --git a/lib/gitlab/auth/ldap/adapter.rb b/lib/gitlab/auth/ldap/adapter.rb index 82ff1e77e5c..42c657afe6a 100644 --- a/lib/gitlab/auth/ldap/adapter.rb +++ b/lib/gitlab/auth/ldap/adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module LDAP diff --git a/lib/gitlab/auth/ldap/auth_hash.rb b/lib/gitlab/auth/ldap/auth_hash.rb index ac5c14d374d..83fdc8a8c76 100644 --- a/lib/gitlab/auth/ldap/auth_hash.rb +++ b/lib/gitlab/auth/ldap/auth_hash.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Class to parse and transform the info provided by omniauth # module Gitlab diff --git a/lib/gitlab/auth/ldap/authentication.rb b/lib/gitlab/auth/ldap/authentication.rb index 7c134fb6438..174e81dd603 100644 --- a/lib/gitlab/auth/ldap/authentication.rb +++ b/lib/gitlab/auth/ldap/authentication.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # These calls help to authenticate to LDAP by providing username and password # # Since multiple LDAP servers are supported, it will loop through all of them diff --git a/lib/gitlab/auth/ldap/config.rb b/lib/gitlab/auth/ldap/config.rb index d4415eaa6dc..7ceb96f502b 100644 --- a/lib/gitlab/auth/ldap/config.rb +++ b/lib/gitlab/auth/ldap/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load a specific server configuration module Gitlab module Auth diff --git a/lib/gitlab/auth/ldap/dn.rb b/lib/gitlab/auth/ldap/dn.rb index 1fa5338f5a6..5df914aa367 100644 --- a/lib/gitlab/auth/ldap/dn.rb +++ b/lib/gitlab/auth/ldap/dn.rb @@ -1,4 +1,5 @@ # -*- ruby encoding: utf-8 -*- +# frozen_string_literal: true # Based on the `ruby-net-ldap` gem's `Net::LDAP::DN` # diff --git a/lib/gitlab/auth/ldap/ldap_connection_error.rb b/lib/gitlab/auth/ldap/ldap_connection_error.rb index ef0a695742b..d0e5f24d203 100644 --- a/lib/gitlab/auth/ldap/ldap_connection_error.rb +++ b/lib/gitlab/auth/ldap/ldap_connection_error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module LDAP diff --git a/lib/gitlab/auth/ldap/person.rb b/lib/gitlab/auth/ldap/person.rb index 8dfae3ee541..a0244a3cea1 100644 --- a/lib/gitlab/auth/ldap/person.rb +++ b/lib/gitlab/auth/ldap/person.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module LDAP diff --git a/lib/gitlab/auth/ldap/user.rb b/lib/gitlab/auth/ldap/user.rb index 3c21ddf3241..9c71671f409 100644 --- a/lib/gitlab/auth/ldap/user.rb +++ b/lib/gitlab/auth/ldap/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # LDAP extension for User model # # * Find or create user from omniauth.auth data diff --git a/lib/gitlab/auth/o_auth/auth_hash.rb b/lib/gitlab/auth/o_auth/auth_hash.rb index ed8fba94305..4a5f9d2839d 100644 --- a/lib/gitlab/auth/o_auth/auth_hash.rb +++ b/lib/gitlab/auth/o_auth/auth_hash.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Class to parse and transform the info provided by omniauth # module Gitlab diff --git a/lib/gitlab/auth/o_auth/authentication.rb b/lib/gitlab/auth/o_auth/authentication.rb index d4e7f35c857..5f008678bd1 100644 --- a/lib/gitlab/auth/o_auth/authentication.rb +++ b/lib/gitlab/auth/o_auth/authentication.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # These calls help to authenticate to OAuth provider by providing username and password # diff --git a/lib/gitlab/auth/o_auth/identity_linker.rb b/lib/gitlab/auth/o_auth/identity_linker.rb index de92d7a214d..e69c2bb54dc 100644 --- a/lib/gitlab/auth/o_auth/identity_linker.rb +++ b/lib/gitlab/auth/o_auth/identity_linker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module OAuth diff --git a/lib/gitlab/auth/o_auth/provider.rb b/lib/gitlab/auth/o_auth/provider.rb index 26da9d09ccc..9fdf3324db3 100644 --- a/lib/gitlab/auth/o_auth/provider.rb +++ b/lib/gitlab/auth/o_auth/provider.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module OAuth diff --git a/lib/gitlab/auth/o_auth/session.rb b/lib/gitlab/auth/o_auth/session.rb index 8f2b4d58552..4925b107042 100644 --- a/lib/gitlab/auth/o_auth/session.rb +++ b/lib/gitlab/auth/o_auth/session.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # :nocov: module Gitlab module Auth diff --git a/lib/gitlab/auth/o_auth/user.rb b/lib/gitlab/auth/o_auth/user.rb index 2b4f6ed75e5..a4e8a41b246 100644 --- a/lib/gitlab/auth/o_auth/user.rb +++ b/lib/gitlab/auth/o_auth/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # OAuth extension for User model # # * Find GitLab user based on omniauth uid and provider diff --git a/lib/gitlab/auth/omniauth_identity_linker_base.rb b/lib/gitlab/auth/omniauth_identity_linker_base.rb index 8ae29a02a13..253445570f2 100644 --- a/lib/gitlab/auth/omniauth_identity_linker_base.rb +++ b/lib/gitlab/auth/omniauth_identity_linker_base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth class OmniauthIdentityLinkerBase diff --git a/lib/gitlab/auth/request_authenticator.rb b/lib/gitlab/auth/request_authenticator.rb index 66de52506ce..cb9f2582936 100644 --- a/lib/gitlab/auth/request_authenticator.rb +++ b/lib/gitlab/auth/request_authenticator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Use for authentication only, in particular for Rack::Attack. # Does not perform authorization of scopes, etc. module Gitlab diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb index 00cdc94a9ef..78fa25c5516 100644 --- a/lib/gitlab/auth/result.rb +++ b/lib/gitlab/auth/result.rb @@ -1,4 +1,7 @@ -module Gitlab # rubocop:disable Naming/FileName +# rubocop:disable Naming/FileName +# frozen_string_literal: true + +module Gitlab module Auth Result = Struct.new(:actor, :project, :type, :authentication_abilities) do def ci?(for_project) diff --git a/lib/gitlab/auth/saml/auth_hash.rb b/lib/gitlab/auth/saml/auth_hash.rb index 3bc5e2864df..316354fd50c 100644 --- a/lib/gitlab/auth/saml/auth_hash.rb +++ b/lib/gitlab/auth/saml/auth_hash.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module Saml diff --git a/lib/gitlab/auth/saml/config.rb b/lib/gitlab/auth/saml/config.rb index 625dab7c6f4..8cb999f50d4 100644 --- a/lib/gitlab/auth/saml/config.rb +++ b/lib/gitlab/auth/saml/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module Saml diff --git a/lib/gitlab/auth/saml/identity_linker.rb b/lib/gitlab/auth/saml/identity_linker.rb index 7e4b191d512..ae0d6dded4e 100644 --- a/lib/gitlab/auth/saml/identity_linker.rb +++ b/lib/gitlab/auth/saml/identity_linker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth module Saml diff --git a/lib/gitlab/auth/saml/user.rb b/lib/gitlab/auth/saml/user.rb index 6c3b75f3eb0..ec95bc46791 100644 --- a/lib/gitlab/auth/saml/user.rb +++ b/lib/gitlab/auth/saml/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # SAML extension for User model # # * Find GitLab user based on SAML uid and provider diff --git a/lib/gitlab/auth/too_many_ips.rb b/lib/gitlab/auth/too_many_ips.rb index ed862791551..ee4d80e6b89 100644 --- a/lib/gitlab/auth/too_many_ips.rb +++ b/lib/gitlab/auth/too_many_ips.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth class TooManyIps < StandardError diff --git a/lib/gitlab/auth/unique_ips_limiter.rb b/lib/gitlab/auth/unique_ips_limiter.rb index baa1f802d8a..31dd61ae6cf 100644 --- a/lib/gitlab/auth/unique_ips_limiter.rb +++ b/lib/gitlab/auth/unique_ips_limiter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth class UniqueIpsLimiter diff --git a/lib/gitlab/auth/user_access_denied_reason.rb b/lib/gitlab/auth/user_access_denied_reason.rb index 1893cb001b2..fd09fe76c02 100644 --- a/lib/gitlab/auth/user_access_denied_reason.rb +++ b/lib/gitlab/auth/user_access_denied_reason.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth class UserAccessDeniedReason diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb index 064cba43278..5df6db6f366 100644 --- a/lib/gitlab/auth/user_auth_finders.rb +++ b/lib/gitlab/auth/user_auth_finders.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth AuthenticationError = Class.new(StandardError) diff --git a/lib/gitlab/badge/base.rb b/lib/gitlab/badge/base.rb index 909fa24fa90..fb55b9e2f1f 100644 --- a/lib/gitlab/badge/base.rb +++ b/lib/gitlab/badge/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge class Base diff --git a/lib/gitlab/badge/coverage/metadata.rb b/lib/gitlab/badge/coverage/metadata.rb index e898f5d790e..9181ba2d4b0 100644 --- a/lib/gitlab/badge/coverage/metadata.rb +++ b/lib/gitlab/badge/coverage/metadata.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Coverage diff --git a/lib/gitlab/badge/coverage/report.rb b/lib/gitlab/badge/coverage/report.rb index 16fd6f01495..a7fcb6b0fca 100644 --- a/lib/gitlab/badge/coverage/report.rb +++ b/lib/gitlab/badge/coverage/report.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Coverage diff --git a/lib/gitlab/badge/coverage/template.rb b/lib/gitlab/badge/coverage/template.rb index afbf9dd17e3..817dc28f84a 100644 --- a/lib/gitlab/badge/coverage/template.rb +++ b/lib/gitlab/badge/coverage/template.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Coverage diff --git a/lib/gitlab/badge/metadata.rb b/lib/gitlab/badge/metadata.rb index 8ad6f3cb986..b9ae68134b0 100644 --- a/lib/gitlab/badge/metadata.rb +++ b/lib/gitlab/badge/metadata.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge ## diff --git a/lib/gitlab/badge/pipeline/metadata.rb b/lib/gitlab/badge/pipeline/metadata.rb index db1e9f8cfb8..d4d789558c9 100644 --- a/lib/gitlab/badge/pipeline/metadata.rb +++ b/lib/gitlab/badge/pipeline/metadata.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Pipeline diff --git a/lib/gitlab/badge/pipeline/status.rb b/lib/gitlab/badge/pipeline/status.rb index d1d9b7949f5..37e61f07e5b 100644 --- a/lib/gitlab/badge/pipeline/status.rb +++ b/lib/gitlab/badge/pipeline/status.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Pipeline diff --git a/lib/gitlab/badge/pipeline/template.rb b/lib/gitlab/badge/pipeline/template.rb index e09db32262d..64c3dfcd10b 100644 --- a/lib/gitlab/badge/pipeline/template.rb +++ b/lib/gitlab/badge/pipeline/template.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge module Pipeline diff --git a/lib/gitlab/badge/template.rb b/lib/gitlab/badge/template.rb index bfeb0052642..ed2ec50b197 100644 --- a/lib/gitlab/badge/template.rb +++ b/lib/gitlab/badge/template.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Badge ## diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb index 04aa6aab771..3cd327f5109 100644 --- a/lib/gitlab/bare_repository_import/importer.rb +++ b/lib/gitlab/bare_repository_import/importer.rb @@ -1,10 +1,15 @@ +# frozen_string_literal: true + module Gitlab module BareRepositoryImport class Importer NoAdminError = Class.new(StandardError) def self.execute(import_path) - import_path << '/' unless import_path.ends_with?('/') + unless import_path.ends_with?('/') + import_path = "#{import_path}/" + end + repos_to_import = Dir.glob(import_path + '**/*.git') unless user = User.admins.order_id_asc.first diff --git a/lib/gitlab/bare_repository_import/repository.rb b/lib/gitlab/bare_repository_import/repository.rb index c0c666dfb7b..b903c581aac 100644 --- a/lib/gitlab/bare_repository_import/repository.rb +++ b/lib/gitlab/bare_repository_import/repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module BareRepositoryImport class Repository @@ -6,9 +8,12 @@ module Gitlab attr_reader :group_path, :project_name, :repo_path def initialize(root_path, repo_path) + unless root_path.ends_with?('/') + root_path = "#{root_path}/" + end + @root_path = root_path @repo_path = repo_path - @root_path << '/' unless root_path.ends_with?('/') full_path = if hashed? && !wiki? diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index a7dfccea2f6..45e550b3450 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module BitbucketImport class Importer diff --git a/lib/gitlab/bitbucket_import/project_creator.rb b/lib/gitlab/bitbucket_import/project_creator.rb index d94f70fd1fb..11070a68e02 100644 --- a/lib/gitlab/bitbucket_import/project_creator.rb +++ b/lib/gitlab/bitbucket_import/project_creator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module BitbucketImport class ProjectCreator diff --git a/lib/gitlab/bitbucket_server_import/project_creator.rb b/lib/gitlab/bitbucket_server_import/project_creator.rb index 35e8cd7e0ab..48ca4951957 100644 --- a/lib/gitlab/bitbucket_server_import/project_creator.rb +++ b/lib/gitlab/bitbucket_server_import/project_creator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module BitbucketServerImport class ProjectCreator diff --git a/lib/gitlab/blob_helper.rb b/lib/gitlab/blob_helper.rb new file mode 100644 index 00000000000..9b3b383b0c8 --- /dev/null +++ b/lib/gitlab/blob_helper.rb @@ -0,0 +1,145 @@ +# This has been extracted from https://github.com/github/linguist/blob/master/lib/linguist/blob_helper.rb +module Gitlab + module BlobHelper + def extname + File.extname(name.to_s) + end + + def known_extension? + LanguageData.extensions.include?(extname) + end + + def viewable? + !large? && text? + end + + MEGABYTE = 1024 * 1024 + + def large? + size.to_i > MEGABYTE + end + + def binary? + # Large blobs aren't even loaded into memory + if data.nil? + true + + # Treat blank files as text + elsif data == "" + false + + # Charlock doesn't know what to think + elsif encoding.nil? + true + + # If Charlock says its binary + else + detect_encoding[:type] == :binary + end + end + + def text? + !binary? + end + + def image? + ['.png', '.jpg', '.jpeg', '.gif'].include?(extname.downcase) + end + + # Internal: Lookup mime type for extension. + # + # Returns a MIME::Type + # rubocop:disable Gitlab/ModuleWithInstanceVariables + def _mime_type + if defined? @_mime_type + @_mime_type + else + guesses = ::MIME::Types.type_for(extname.to_s) + + # Prefer text mime types over binary + @_mime_type = guesses.detect { |type| type.ascii? } || guesses.first + end + end + # rubocop:enable Gitlab/ModuleWithInstanceVariables + + # Public: Get the actual blob mime type + # + # Examples + # + # # => 'text/plain' + # # => 'text/html' + # + # Returns a mime type String. + def mime_type + _mime_type ? _mime_type.to_s : 'text/plain' + end + + def binary_mime_type? + _mime_type ? _mime_type.binary? : false + end + + def lines + @lines ||= + if viewable? && data + # `data` is usually encoded as ASCII-8BIT even when the content has + # been detected as a different encoding. However, we are not allowed + # to change the encoding of `data` because we've made the implicit + # guarantee that each entry in `lines` is encoded the same way as + # `data`. + # + # Instead, we re-encode each possible newline sequence as the + # detected encoding, then force them back to the encoding of `data` + # (usually a binary encoding like ASCII-8BIT). This means that the + # byte sequence will match how newlines are likely encoded in the + # file, but we don't have to change the encoding of `data` as far as + # Ruby is concerned. This allows us to correctly parse out each line + # without changing the encoding of `data`, and + # also--importantly--without having to duplicate many (potentially + # large) strings. + begin + data.split(encoded_newlines_re, -1) + rescue Encoding::ConverterNotFoundError + # The data is not splittable in the detected encoding. Assume it's + # one big line. + [data] + end + else + [] + end + end + + def content_type + # rubocop:disable Style/MultilineTernaryOperator + # rubocop:disable Style/NestedTernaryOperator + @content_type ||= binary_mime_type? || binary? ? mime_type : + (encoding ? "text/plain; charset=#{encoding.downcase}" : "text/plain") + # rubocop:enable Style/NestedTernaryOperator + # rubocop:enable Style/MultilineTernaryOperator + end + + def encoded_newlines_re + @encoded_newlines_re ||= + Regexp.union(["\r\n", "\r", "\n"].map { |nl| nl.encode(ruby_encoding, "ASCII-8BIT").force_encoding(data.encoding) }) + end + + def ruby_encoding + if hash = detect_encoding + hash[:ruby_encoding] + end + end + + def encoding + if hash = detect_encoding + hash[:encoding] + end + end + + def detect_encoding + @detect_encoding ||= CharlockHolmes::EncodingDetector.new.detect(data) if data # rubocop:disable Gitlab/ModuleWithInstanceVariables + end + + def empty? + data.nil? || data == "" + end + end +end diff --git a/lib/gitlab/cache/ci/project_pipeline_status.rb b/lib/gitlab/cache/ci/project_pipeline_status.rb index add048d671e..b369b9e7600 100644 --- a/lib/gitlab/cache/ci/project_pipeline_status.rb +++ b/lib/gitlab/cache/ci/project_pipeline_status.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class is not backed by a table in the main database. # It loads the latest Pipeline for the HEAD of a repository, and caches that # in Redis. diff --git a/lib/gitlab/cache/request_cache.rb b/lib/gitlab/cache/request_cache.rb index b96e161a5b6..4c658dc0b8d 100644 --- a/lib/gitlab/cache/request_cache.rb +++ b/lib/gitlab/cache/request_cache.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Cache # See https://docs.gitlab.com/ee/development/utilities.html#requestcache diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb index 7a4224e5bbe..49e7f7e1fd7 100644 --- a/lib/gitlab/checks/change_access.rb +++ b/lib/gitlab/checks/change_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class ChangeAccess diff --git a/lib/gitlab/checks/commit_check.rb b/lib/gitlab/checks/commit_check.rb index 7e0c34aada3..6dd74e8fb74 100644 --- a/lib/gitlab/checks/commit_check.rb +++ b/lib/gitlab/checks/commit_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class CommitCheck diff --git a/lib/gitlab/checks/force_push.rb b/lib/gitlab/checks/force_push.rb index 87af4a90572..263972923ed 100644 --- a/lib/gitlab/checks/force_push.rb +++ b/lib/gitlab/checks/force_push.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class ForcePush diff --git a/lib/gitlab/checks/lfs_integrity.rb b/lib/gitlab/checks/lfs_integrity.rb index 3f7adecc621..fa3dc1808df 100644 --- a/lib/gitlab/checks/lfs_integrity.rb +++ b/lib/gitlab/checks/lfs_integrity.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class LfsIntegrity diff --git a/lib/gitlab/checks/matching_merge_request.rb b/lib/gitlab/checks/matching_merge_request.rb index 86f4aaeb4d3..71361b12d07 100644 --- a/lib/gitlab/checks/matching_merge_request.rb +++ b/lib/gitlab/checks/matching_merge_request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class MatchingMergeRequest diff --git a/lib/gitlab/checks/post_push_message.rb b/lib/gitlab/checks/post_push_message.rb index 473c0385b34..492dbb5a596 100644 --- a/lib/gitlab/checks/post_push_message.rb +++ b/lib/gitlab/checks/post_push_message.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class PostPushMessage diff --git a/lib/gitlab/checks/project_created.rb b/lib/gitlab/checks/project_created.rb index cec270d6a58..0058a402a62 100644 --- a/lib/gitlab/checks/project_created.rb +++ b/lib/gitlab/checks/project_created.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class ProjectCreated < PostPushMessage diff --git a/lib/gitlab/checks/project_moved.rb b/lib/gitlab/checks/project_moved.rb index 3a197078d08..cb3b7acaaad 100644 --- a/lib/gitlab/checks/project_moved.rb +++ b/lib/gitlab/checks/project_moved.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Checks class ProjectMoved < PostPushMessage diff --git a/lib/gitlab/ci/templates/Android.gitlab-ci.yml b/lib/gitlab/ci/templates/Android.gitlab-ci.yml index 5f9d54ff574..bf7831b937c 100644 --- a/lib/gitlab/ci/templates/Android.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Android.gitlab-ci.yml @@ -2,33 +2,33 @@ image: openjdk:8-jdk variables: - ANDROID_COMPILE_SDK: "25" - ANDROID_BUILD_TOOLS: "24.0.0" - ANDROID_SDK_TOOLS: "24.4.1" + ANDROID_COMPILE_SDK: "28" + ANDROID_BUILD_TOOLS: "28.0.3" + ANDROID_SDK_TOOLS: "26.1.1" before_script: - - apt-get --quiet update --yes - - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 - - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz - - tar --extract --gzip --file=android-sdk.tgz - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK} - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS} - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services - - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository - - export ANDROID_HOME=$PWD/android-sdk-linux - - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ - - chmod +x ./gradlew +- apt-get --quiet update --yes +- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 +- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip +- unzip android-sdk.zip -d android-sdk-linux +- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null +- echo y | android-sdk-linux/tools/bin/sdkmanager platform-tools > /dev/null +- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" > /dev/null +- echo y | android-sdk-linux/tools/bin/sdkmanager "extras;google;google_play_services" > /dev/null +- echo y | android-sdk-linux/tools/bin/sdkmanager "extras;google;m2repository" > /dev/null +- export ANDROID_HOME=$PWD/android-sdk-linux +- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ +- yes | android-sdk-linux/tools/bin/sdkmanager --licenses & +- chmod +x ./gradlew stages: - - build - - test +- build +- test build: stage: build script: - - ./gradlew assembleDebug + - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/ @@ -36,7 +36,7 @@ build: unitTests: stage: test script: - - ./gradlew test + - ./gradlew test functionalTests: stage: test diff --git a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml index 72547c1b407..6fa59e41d20 100644 --- a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @@ -126,8 +126,8 @@ license_management: artifacts: paths: [gl-license-management-report.json] only: - - branches - only: + refs: + - branches variables: - $GITLAB_FEATURES =~ /\blicense_management\b/ except: diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb index 2a0cb640a14..30911b49b18 100644 --- a/lib/gitlab/conflict/file.rb +++ b/lib/gitlab/conflict/file.rb @@ -158,7 +158,6 @@ module Gitlab json_hash.tap do |json_hash| if opts[:full_content] json_hash[:content] = content - json_hash[:blob_ace_mode] = our_blob && our_blob.language.try(:ace_mode) else json_hash[:sections] = sections if type.text? json_hash[:type] = type diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb index 8f55e94975c..da62ed2fb16 100644 --- a/lib/gitlab/file_detector.rb +++ b/lib/gitlab/file_detector.rb @@ -18,7 +18,6 @@ module Gitlab # Configuration files gitignore: '.gitignore', - koding: '.koding.yml', gitlab_ci: '.gitlab-ci.yml', route_map: '.gitlab/route-map.yml', diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb index 71857bd2d87..13b0bb930f4 100644 --- a/lib/gitlab/git/blob.rb +++ b/lib/gitlab/git/blob.rb @@ -3,13 +3,13 @@ module Gitlab module Git class Blob - include Linguist::BlobHelper + include Gitlab::BlobHelper include Gitlab::EncodingHelper # This number is the maximum amount of data that we want to display to - # the user. We load as much as we can for encoding detection - # (Linguist) and LFS pointer parsing. All other cases where we need full - # blob data should use load_all_data!. + # the user. We load as much as we can for encoding detection and LFS + # pointer parsing. All other cases where we need full blob data should + # use load_all_data!. MAX_DATA_DISPLAY_SIZE = 10.megabytes # These limits are used as a heuristic to ignore files which can't be LFS diff --git a/lib/gitlab/git/blob_snippet.rb b/lib/gitlab/git/blob_snippet.rb deleted file mode 100644 index 68116e775c6..00000000000 --- a/lib/gitlab/git/blob_snippet.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Gitaly note: JV: no RPC's here. - -module Gitlab - module Git - class BlobSnippet - include Linguist::BlobHelper - - attr_accessor :ref - attr_accessor :lines - attr_accessor :filename - attr_accessor :startline - - def initialize(ref, lines, startline, filename) - @ref, @lines, @startline, @filename = ref, lines, startline, filename - end - - def data - lines&.join("\n") - end - - def name - filename - end - - def size - data.length - end - - def mode - nil - end - end - end -end diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 7732049b69b..9df04372cc2 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -96,10 +96,6 @@ module Gitlab raise Gitlab::Git::CommandError.new(e.message) end - def circuit_breaker - @circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(storage) - end - def exists? gitaly_repository_client.exists? end @@ -386,9 +382,9 @@ module Gitlab end # Returns the SHA of the most recent common ancestor of +from+ and +to+ - def merge_base(from, to) + def merge_base(*commits) wrapped_gitaly_errors do - gitaly_repository_client.find_merge_base(from, to) + gitaly_repository_client.find_merge_base(*commits) end end diff --git a/lib/gitlab/git/storage.rb b/lib/gitlab/git/storage.rb deleted file mode 100644 index 5933312b0b5..00000000000 --- a/lib/gitlab/git/storage.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Gitlab - module Git - module Storage - class Inaccessible < StandardError - attr_reader :retry_after - - def initialize(message = nil, retry_after = nil) - super(message) - @retry_after = retry_after - end - end - - CircuitOpen = Class.new(Inaccessible) - Misconfiguration = Class.new(Inaccessible) - Failing = Class.new(Inaccessible) - - REDIS_KEY_PREFIX = 'storage_accessible:'.freeze - REDIS_KNOWN_KEYS = "#{REDIS_KEY_PREFIX}known_keys_set".freeze - - def self.redis - Gitlab::Redis::SharedState - end - end - end -end diff --git a/lib/gitlab/git/storage/checker.rb b/lib/gitlab/git/storage/checker.rb deleted file mode 100644 index 391f0d70583..00000000000 --- a/lib/gitlab/git/storage/checker.rb +++ /dev/null @@ -1,120 +0,0 @@ -module Gitlab - module Git - module Storage - class Checker - include CircuitBreakerSettings - - attr_reader :storage_path, :storage, :hostname, :logger - METRICS_MUTEX = Mutex.new - STORAGE_TIMING_BUCKETS = [0.1, 0.15, 0.25, 0.33, 0.5, 1, 1.5, 2.5, 5, 10, 15].freeze - - def self.check_all(logger = Rails.logger) - threads = Gitlab.config.repositories.storages.keys.map do |storage_name| - Thread.new do - Thread.current[:result] = new(storage_name, logger).check_with_lease - end - end - - threads.map do |thread| - thread.join - thread[:result] - end - end - - def self.check_histogram - @check_histogram ||= - METRICS_MUTEX.synchronize do - @check_histogram || Gitlab::Metrics.histogram(:circuitbreaker_storage_check_duration_seconds, - 'Storage check time in seconds', - {}, - STORAGE_TIMING_BUCKETS - ) - end - end - - def initialize(storage, logger = Rails.logger) - @storage = storage - config = Gitlab.config.repositories.storages[@storage] - @storage_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { config.legacy_disk_path } - @logger = logger - - @hostname = Gitlab::Environment.hostname - end - - def check_with_lease - lease_key = "storage_check:#{cache_key}" - lease = Gitlab::ExclusiveLease.new(lease_key, timeout: storage_timeout) - result = { storage: storage, success: nil } - - if uuid = lease.try_obtain - result[:success] = check - - Gitlab::ExclusiveLease.cancel(lease_key, uuid) - else - logger.warn("#{hostname}: #{storage}: Skipping check, previous check still running") - end - - result - end - - def check - if perform_access_check - track_storage_accessible - true - else - track_storage_inaccessible - logger.error("#{hostname}: #{storage}: Not accessible.") - false - end - end - - private - - def perform_access_check - start_time = Gitlab::Metrics::System.monotonic_time - - Gitlab::Git::Storage::ForkedStorageCheck.storage_available?(storage_path, storage_timeout, access_retries) - ensure - execution_time = Gitlab::Metrics::System.monotonic_time - start_time - self.class.check_histogram.observe({ storage: storage }, execution_time) - end - - def track_storage_inaccessible - first_failure = current_failure_info.first_failure || Time.now - last_failure = Time.now - - Gitlab::Git::Storage.redis.with do |redis| - redis.pipelined do - redis.hset(cache_key, :first_failure, first_failure.to_i) - redis.hset(cache_key, :last_failure, last_failure.to_i) - redis.hincrby(cache_key, :failure_count, 1) - redis.expire(cache_key, failure_reset_time) - maintain_known_keys(redis) - end - end - end - - def track_storage_accessible - Gitlab::Git::Storage.redis.with do |redis| - redis.pipelined do - redis.hset(cache_key, :first_failure, nil) - redis.hset(cache_key, :last_failure, nil) - redis.hset(cache_key, :failure_count, 0) - maintain_known_keys(redis) - end - end - end - - def maintain_known_keys(redis) - expire_time = Time.now.to_i + failure_reset_time - redis.zadd(Gitlab::Git::Storage::REDIS_KNOWN_KEYS, expire_time, cache_key) - redis.zremrangebyscore(Gitlab::Git::Storage::REDIS_KNOWN_KEYS, '-inf', Time.now.to_i) - end - - def current_failure_info - FailureInfo.load(cache_key) - end - end - end - end -end diff --git a/lib/gitlab/git/storage/circuit_breaker.rb b/lib/gitlab/git/storage/circuit_breaker.rb deleted file mode 100644 index fcee9ae566c..00000000000 --- a/lib/gitlab/git/storage/circuit_breaker.rb +++ /dev/null @@ -1,78 +0,0 @@ -module Gitlab - module Git - module Storage - class CircuitBreaker - include CircuitBreakerSettings - - attr_reader :storage, - :hostname - - delegate :last_failure, :failure_count, :no_failures?, - to: :failure_info - - def self.for_storage(storage) - cached_circuitbreakers = Gitlab::SafeRequestStore.fetch(:circuitbreaker_cache) do - Hash.new do |hash, storage_name| - hash[storage_name] = build(storage_name) - end - end - - cached_circuitbreakers[storage] - end - - def self.build(storage, hostname = Gitlab::Environment.hostname) - config = Gitlab.config.repositories.storages[storage] - Gitlab::GitalyClient::StorageSettings.allow_disk_access do - if !config.present? - NullCircuitBreaker.new(storage, hostname, error: Misconfiguration.new("Storage '#{storage}' is not configured")) - elsif !config.legacy_disk_path.present? - NullCircuitBreaker.new(storage, hostname, error: Misconfiguration.new("Path for storage '#{storage}' is not configured")) - else - new(storage, hostname) - end - end - end - - def initialize(storage, hostname) - @storage = storage - @hostname = hostname - end - - def perform - return yield unless enabled? - - check_storage_accessible! - - yield - end - - def circuit_broken? - return false if no_failures? - - failure_count > failure_count_threshold - end - - private - - # The circuitbreaker can be enabled for the entire fleet using a Feature - # flag. - # - # Enabling it for a single host can be done setting the - # `GIT_STORAGE_CIRCUIT_BREAKER` environment variable. - def enabled? - ENV['GIT_STORAGE_CIRCUIT_BREAKER'].present? || Feature.enabled?('git_storage_circuit_breaker') - end - - def failure_info - @failure_info ||= FailureInfo.load(cache_key) - end - - def check_storage_accessible! - if circuit_broken? - raise Gitlab::Git::Storage::CircuitOpen.new("Circuit for #{storage} is broken", failure_reset_time) - end - end - end - end - end -end diff --git a/lib/gitlab/git/storage/circuit_breaker_settings.rb b/lib/gitlab/git/storage/circuit_breaker_settings.rb deleted file mode 100644 index c9e225f187d..00000000000 --- a/lib/gitlab/git/storage/circuit_breaker_settings.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Gitlab - module Git - module Storage - module CircuitBreakerSettings - def failure_count_threshold - application_settings.circuitbreaker_failure_count_threshold - end - - def failure_reset_time - application_settings.circuitbreaker_failure_reset_time - end - - def storage_timeout - application_settings.circuitbreaker_storage_timeout - end - - def access_retries - application_settings.circuitbreaker_access_retries - end - - def check_interval - application_settings.circuitbreaker_check_interval - end - - def cache_key - @cache_key ||= "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}#{storage}:#{hostname}" - end - - private - - def application_settings - Gitlab::CurrentSettings.current_application_settings - end - end - end - end -end diff --git a/lib/gitlab/git/storage/failure_info.rb b/lib/gitlab/git/storage/failure_info.rb deleted file mode 100644 index 1d28a850049..00000000000 --- a/lib/gitlab/git/storage/failure_info.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Gitlab - module Git - module Storage - class FailureInfo - attr_accessor :first_failure, :last_failure, :failure_count - - def self.reset_all! - Gitlab::Git::Storage.redis.with do |redis| - all_storage_keys = redis.zrange(Gitlab::Git::Storage::REDIS_KNOWN_KEYS, 0, -1) - redis.del(*all_storage_keys) unless all_storage_keys.empty? - end - - Gitlab::SafeRequestStore.delete(:circuitbreaker_cache) - end - - def self.load(cache_key) - first_failure, last_failure, failure_count = Gitlab::Git::Storage.redis.with do |redis| - redis.hmget(cache_key, :first_failure, :last_failure, :failure_count) - end - - last_failure = Time.at(last_failure.to_i) if last_failure.present? - first_failure = Time.at(first_failure.to_i) if first_failure.present? - - new(first_failure, last_failure, failure_count.to_i) - end - - def initialize(first_failure, last_failure, failure_count) - @first_failure = first_failure - @last_failure = last_failure - @failure_count = failure_count - end - - def no_failures? - first_failure.blank? && last_failure.blank? && failure_count == 0 - end - end - end - end -end diff --git a/lib/gitlab/git/storage/forked_storage_check.rb b/lib/gitlab/git/storage/forked_storage_check.rb deleted file mode 100644 index 0a4e557b59b..00000000000 --- a/lib/gitlab/git/storage/forked_storage_check.rb +++ /dev/null @@ -1,65 +0,0 @@ -module Gitlab - module Git - module Storage - module ForkedStorageCheck - extend self - - def storage_available?(path, timeout_seconds = 5, retries = 1) - partial_timeout = timeout_seconds / retries - status = timeout_check(path, partial_timeout) - - # If the status check did not succeed the first time, we retry a few - # more times to avoid one-off failures - current_attempts = 1 - while current_attempts < retries && !status.success? - status = timeout_check(path, partial_timeout) - current_attempts += 1 - end - - status.success? - end - - def timeout_check(path, timeout_seconds) - filesystem_check_pid = check_filesystem_in_process(path) - - deadline = timeout_seconds.seconds.from_now.utc - wait_time = 0.01 - status = nil - - while status.nil? - - if deadline > Time.now.utc - sleep(wait_time) - _pid, status = Process.wait2(filesystem_check_pid, Process::WNOHANG) - else - Process.kill('KILL', filesystem_check_pid) - # Blocking wait, so we are sure the process is gone before continuing - _pid, status = Process.wait2(filesystem_check_pid) - end - end - - status - end - - # This will spawn a new 2 processes to do the check: - # The outer child (waiter) will spawn another child process (stater). - # - # The stater is the process is performing the actual filesystem check - # the check might hang if the filesystem is acting up. - # In this case we will send a `KILL` to the waiter, which will still - # be responsive while the stater is hanging. - def check_filesystem_in_process(path) - spawn('ruby', '-e', ruby_check, path, [:out, :err] => '/dev/null') - end - - def ruby_check - <<~RUBY_FILESYSTEM_CHECK - inner_pid = fork { File.stat(ARGV.first) } - Process.waitpid(inner_pid) - exit $?.exitstatus - RUBY_FILESYSTEM_CHECK - end - end - end - end -end diff --git a/lib/gitlab/git/storage/health.rb b/lib/gitlab/git/storage/health.rb deleted file mode 100644 index 8e14acb4ccb..00000000000 --- a/lib/gitlab/git/storage/health.rb +++ /dev/null @@ -1,92 +0,0 @@ -module Gitlab - module Git - module Storage - class Health - attr_reader :storage_name, :info - - def self.prefix_for_storage(storage_name) - "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}#{storage_name}:" - end - - def self.for_all_storages - storage_names = Gitlab.config.repositories.storages.keys - results_per_storage = nil - - Gitlab::Git::Storage.redis.with do |redis| - keys_per_storage = all_keys_for_storages(storage_names, redis) - results_per_storage = load_for_keys(keys_per_storage, redis) - end - - results_per_storage.map do |name, info| - info.each { |i| i[:failure_count] = i[:failure_count].value.to_i } - new(name, info) - end - end - - private_class_method def self.all_keys_for_storages(storage_names, redis) - keys_per_storage = {} - all_keys = redis.zrange(Gitlab::Git::Storage::REDIS_KNOWN_KEYS, 0, -1) - - storage_names.each do |storage_name| - prefix = prefix_for_storage(storage_name) - - keys_per_storage[storage_name] = all_keys.select { |key| key.starts_with?(prefix) } - end - - keys_per_storage - end - - private_class_method def self.load_for_keys(keys_per_storage, redis) - info_for_keys = {} - - redis.pipelined do - keys_per_storage.each do |storage_name, keys_future| - info_for_storage = keys_future.map do |key| - { name: key, failure_count: redis.hget(key, :failure_count) } - end - - info_for_keys[storage_name] = info_for_storage - end - end - - info_for_keys - end - - def self.for_failing_storages - for_all_storages.select(&:failing?) - end - - def initialize(storage_name, info) - @storage_name = storage_name - @info = info - end - - def failing_info - @failing_info ||= info.select { |info_for_host| info_for_host[:failure_count] > 0 } - end - - def failing? - failing_info.any? - end - - def failing_on_hosts - @failing_on_hosts ||= failing_info.map do |info_for_host| - info_for_host[:name].split(':').last - end - end - - def failing_circuit_breakers - @failing_circuit_breakers ||= failing_on_hosts.map do |hostname| - CircuitBreaker.build(storage_name, hostname) - end - end - - # rubocop: disable CodeReuse/ActiveRecord - def total_failures - @total_failures ||= failing_info.sum { |info_for_host| info_for_host[:failure_count] } - end - # rubocop: enable CodeReuse/ActiveRecord - end - end - end -end diff --git a/lib/gitlab/git/storage/null_circuit_breaker.rb b/lib/gitlab/git/storage/null_circuit_breaker.rb deleted file mode 100644 index 261c936c689..00000000000 --- a/lib/gitlab/git/storage/null_circuit_breaker.rb +++ /dev/null @@ -1,50 +0,0 @@ -module Gitlab - module Git - module Storage - class NullCircuitBreaker - include CircuitBreakerSettings - - # These will have actual values - attr_reader :storage, - :hostname - - # These will always have nil values - attr_reader :storage_path - - delegate :last_failure, :failure_count, :no_failures?, - to: :failure_info - - def initialize(storage, hostname, error: nil) - @storage = storage - @hostname = hostname - @error = error - end - - def perform - @error ? raise(@error) : yield - end - - def circuit_broken? - !!@error - end - - def backing_off? - false - end - - def failure_info - @failure_info ||= - if circuit_broken? - Gitlab::Git::Storage::FailureInfo.new(Time.now, - Time.now, - failure_count_threshold) - else - Gitlab::Git::Storage::FailureInfo.new(nil, - nil, - 0) - end - end - end - end - end -end diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index deaa14c8434..c1726659a90 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -30,5 +30,20 @@ module Gitlab gon.current_user_avatar_url = current_user.avatar_url end end + + # Exposes the state of a feature flag to the frontend code. + # + # name - The name of the feature flag, e.g. `my_feature`. + # args - Any additional arguments to pass to `Feature.enabled?`. This allows + # you to check if a flag is enabled for a particular user. + def push_frontend_feature_flag(name, *args) + var_name = name.to_s.camelize(:lower) + enabled = Feature.enabled?(name, *args) + + # Here the `true` argument signals gon that the value should be merged + # into any existing ones, instead of overwriting them. This allows you to + # use this method to push multiple feature flags. + gon.push({ features: { var_name => enabled } }, true) + end end end diff --git a/lib/gitlab/hook_data/base_builder.rb b/lib/gitlab/hook_data/base_builder.rb index 4ffca356b29..1a91301e8be 100644 --- a/lib/gitlab/hook_data/base_builder.rb +++ b/lib/gitlab/hook_data/base_builder.rb @@ -25,6 +25,7 @@ module Gitlab markdown_text.gsub(MARKDOWN_SIMPLE_IMAGE) do if $~[:image] url = $~[:url] + url = "#{uploads_prefix}#{url}" if url.start_with?('/uploads') url = "/#{url}" unless url.start_with?('/') "![#{$~[:title]}](#{Gitlab.config.gitlab.url}#{url})" @@ -33,6 +34,16 @@ module Gitlab end end end + + def uploads_prefix + project&.full_path || '' + end + + def project + return unless object.respond_to?(:project) + + object.project + end end end end diff --git a/lib/gitlab/language_data.rb b/lib/gitlab/language_data.rb new file mode 100644 index 00000000000..bfdd7175198 --- /dev/null +++ b/lib/gitlab/language_data.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Gitlab + module LanguageData + EXTENSION_MUTEX = Mutex.new + + class << self + include Gitlab::Utils::StrongMemoize + + def extensions + EXTENSION_MUTEX.synchronize do + strong_memoize(:extensions) do + Set.new.tap do |set| + YAML.load_file(Rails.root.join('vendor', 'languages.yml')).each do |_name, details| + details['extensions']&.each do |ext| + next unless ext.start_with?('.') + + set << ext.downcase + end + end + end + end + end + end + + def clear_extensions! + EXTENSION_MUTEX.synchronize do + clear_memoization(:extensions) + end + end + end + end +end diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index 359dd2bcbc7..a78314afdb2 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -39,7 +39,6 @@ module Gitlab import invites jwt - koding login notification_settings oauth diff --git a/lib/gitlab/storage_check.rb b/lib/gitlab/storage_check.rb deleted file mode 100644 index fe81513c9ec..00000000000 --- a/lib/gitlab/storage_check.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative 'storage_check/cli' -require_relative 'storage_check/gitlab_caller' -require_relative 'storage_check/option_parser' -require_relative 'storage_check/response' - -module Gitlab - module StorageCheck - ENDPOINT = '/-/storage_check'.freeze - Options = Struct.new(:target, :token, :interval, :dryrun) - end -end diff --git a/lib/gitlab/storage_check/cli.rb b/lib/gitlab/storage_check/cli.rb deleted file mode 100644 index 9b64c8e033a..00000000000 --- a/lib/gitlab/storage_check/cli.rb +++ /dev/null @@ -1,71 +0,0 @@ -module Gitlab - module StorageCheck - class CLI - def self.start!(args) - runner = new(Gitlab::StorageCheck::OptionParser.parse!(args)) - runner.start_loop - end - - attr_reader :logger, :options - - def initialize(options) - @options = options - @logger = Logger.new(STDOUT) - end - - def start_loop - logger.info "Checking #{options.target} every #{options.interval} seconds" - - if options.dryrun - logger.info "Dryrun, exiting..." - return - end - - begin - loop do - response = GitlabCaller.new(options).call! - log_response(response) - update_settings(response) - - sleep options.interval - end - rescue Interrupt - logger.info "Ending storage-check" - end - end - - def update_settings(response) - previous_interval = options.interval - - if response.valid? - options.interval = response.check_interval || previous_interval - end - - if previous_interval != options.interval - logger.info "Interval changed: #{options.interval} seconds" - end - end - - def log_response(response) - unless response.valid? - return logger.error("Invalid response checking nfs storage: #{response.http_response.inspect}") - end - - if response.responsive_shards.any? - logger.debug("Responsive shards: #{response.responsive_shards.join(', ')}") - end - - warnings = [] - if response.skipped_shards.any? - warnings << "Skipped shards: #{response.skipped_shards.join(', ')}" - end - - if response.failing_shards.any? - warnings << "Failing shards: #{response.failing_shards.join(', ')}" - end - - logger.warn(warnings.join(' - ')) if warnings.any? - end - end - end -end diff --git a/lib/gitlab/storage_check/gitlab_caller.rb b/lib/gitlab/storage_check/gitlab_caller.rb deleted file mode 100644 index 44952b68844..00000000000 --- a/lib/gitlab/storage_check/gitlab_caller.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'excon' - -module Gitlab - module StorageCheck - class GitlabCaller - def initialize(options) - @options = options - end - - def call! - Gitlab::StorageCheck::Response.new(get_response) - rescue Errno::ECONNREFUSED, Excon::Error - # Server not ready, treated as invalid response. - Gitlab::StorageCheck::Response.new(nil) - end - - def get_response - scheme, *other_parts = URI.split(@options.target) - socket_path = if scheme == 'unix' - other_parts.compact.join - end - - connection = Excon.new(@options.target, socket: socket_path) - connection.post(path: Gitlab::StorageCheck::ENDPOINT, - headers: headers) - end - - def headers - @headers ||= begin - headers = {} - headers['Content-Type'] = headers['Accept'] = 'application/json' - headers['TOKEN'] = @options.token if @options.token - - headers - end - end - end - end -end diff --git a/lib/gitlab/storage_check/option_parser.rb b/lib/gitlab/storage_check/option_parser.rb deleted file mode 100644 index 66ed7906f97..00000000000 --- a/lib/gitlab/storage_check/option_parser.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Gitlab - module StorageCheck - class OptionParser - def self.parse!(args) - # Start out with some defaults - options = Gitlab::StorageCheck::Options.new(nil, nil, 1, false) - - parser = ::OptionParser.new do |opts| - opts.banner = "Usage: bin/storage_check [options]" - - opts.on('-t=string', '--target string', 'URL or socket to trigger storage check') do |value| - options.target = value - end - - opts.on('-T=string', '--token string', 'Health token to use') { |value| options.token = value } - - opts.on('-i=n', '--interval n', ::OptionParser::DecimalInteger, 'Seconds between checks') do |value| - options.interval = value - end - - opts.on('-d', '--dryrun', "Output what will be performed, but don't start the process") do |value| - options.dryrun = value - end - end - parser.parse!(args) - - unless options.target - raise ::OptionParser::InvalidArgument.new('Provide a URI to provide checks') - end - - if URI.parse(options.target).scheme.nil? - raise ::OptionParser::InvalidArgument.new('Add the scheme to the target, `unix://`, `https://` or `http://` are supported') - end - - options - end - end - end -end diff --git a/lib/gitlab/storage_check/response.rb b/lib/gitlab/storage_check/response.rb deleted file mode 100644 index 326ab236e3e..00000000000 --- a/lib/gitlab/storage_check/response.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'json' - -module Gitlab - module StorageCheck - class Response - attr_reader :http_response - - def initialize(http_response) - @http_response = http_response - end - - def valid? - @http_response && (200...299).cover?(@http_response.status) && - @http_response.headers['Content-Type'].include?('application/json') && - parsed_response - end - - def check_interval - return nil unless parsed_response - - parsed_response['check_interval'] - end - - def responsive_shards - divided_results[:responsive_shards] - end - - def skipped_shards - divided_results[:skipped_shards] - end - - def failing_shards - divided_results[:failing_shards] - end - - private - - def results - return [] unless parsed_response - - parsed_response['results'] - end - - def divided_results - return @divided_results if @divided_results - - @divided_results = {} - @divided_results[:responsive_shards] = [] - @divided_results[:skipped_shards] = [] - @divided_results[:failing_shards] = [] - - results.each do |info| - name = info['storage'] - - case info['success'] - when true - @divided_results[:responsive_shards] << name - when false - @divided_results[:failing_shards] << name - else - @divided_results[:skipped_shards] << name - end - end - - @divided_results - end - - def parsed_response - return @parsed_response if defined?(@parsed_response) - - @parsed_response = JSON.parse(@http_response.body) - rescue JSON::JSONError - @parsed_response = nil - end - end - end -end diff --git a/lib/google_api/auth.rb b/lib/google_api/auth.rb index 1aeaa387a49..e724e58e9ca 100644 --- a/lib/google_api/auth.rb +++ b/lib/google_api/auth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module GoogleApi class Auth attr_reader :access_token, :redirect_uri, :state diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index 77b6610286f..e74ff6a9129 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'google/apis/compute_v1' require 'google/apis/container_v1' require 'google/apis/cloudbilling_v1' diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb index adbed20f152..5ecd6169ecf 100644 --- a/lib/haml_lint/inline_javascript.rb +++ b/lib/haml_lint/inline_javascript.rb @@ -1,4 +1,7 @@ -unless Rails.env.production? # rubocop:disable Naming/FileName +# rubocop:disable Naming/FileName +# frozen_string_literal: true + +unless Rails.env.production? require 'haml_lint/haml_visitor' require 'haml_lint/linter' require 'haml_lint/linter_registry' diff --git a/lib/json_web_token/rsa_token.rb b/lib/json_web_token/rsa_token.rb index d6d6af7089c..160e1e506f1 100644 --- a/lib/json_web_token/rsa_token.rb +++ b/lib/json_web_token/rsa_token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module JSONWebToken class RSAToken < Token attr_reader :key_file diff --git a/lib/json_web_token/token.rb b/lib/json_web_token/token.rb index 5b67715b0b2..ce5d6f248d0 100644 --- a/lib/json_web_token/token.rb +++ b/lib/json_web_token/token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module JSONWebToken class Token attr_accessor :issuer, :subject, :audience, :id diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb index d80cd7d2a4e..293d0c563c5 100644 --- a/lib/mattermost/client.rb +++ b/lib/mattermost/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost ClientError = Class.new(Mattermost::Error) diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb index 704813dfdf0..a02745486d6 100644 --- a/lib/mattermost/command.rb +++ b/lib/mattermost/command.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class Command < Client def create(params) diff --git a/lib/mattermost/error.rb b/lib/mattermost/error.rb index dee6deb7974..054bd5457bd 100644 --- a/lib/mattermost/error.rb +++ b/lib/mattermost/error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost Error = Class.new(StandardError) end diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index 2aa7a2f64d8..e2083848a8d 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class NoSessionError < Mattermost::Error def message diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb index 95c2f6f9d6b..58120178f50 100644 --- a/lib/mattermost/team.rb +++ b/lib/mattermost/team.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class Team < Client # Returns all teams that the current user is a member of diff --git a/lib/microsoft_teams/activity.rb b/lib/microsoft_teams/activity.rb index d2c420efdaf..207e90d2638 100644 --- a/lib/microsoft_teams/activity.rb +++ b/lib/microsoft_teams/activity.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MicrosoftTeams class Activity def initialize(title:, subtitle:, text:, image:) diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb index 226ee1373db..c7dec09ba6b 100644 --- a/lib/microsoft_teams/notifier.rb +++ b/lib/microsoft_teams/notifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MicrosoftTeams class Notifier def initialize(webhook) diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb index 97f56e10ccf..fd26663fef0 100644 --- a/lib/object_storage/direct_upload.rb +++ b/lib/object_storage/direct_upload.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ObjectStorage # # The DirectUpload c;ass generates a set of presigned URLs diff --git a/lib/omni_auth/strategies/bitbucket.rb b/lib/omni_auth/strategies/bitbucket.rb index ce1bdfe6ee4..6c914b4222a 100644 --- a/lib/omni_auth/strategies/bitbucket.rb +++ b/lib/omni_auth/strategies/bitbucket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'omniauth-oauth2' module OmniAuth diff --git a/lib/omni_auth/strategies/jwt.rb b/lib/omni_auth/strategies/jwt.rb index ebdb5c7faf0..a792903fde7 100644 --- a/lib/omni_auth/strategies/jwt.rb +++ b/lib/omni_auth/strategies/jwt.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'omniauth' require 'jwt' diff --git a/lib/peek/rblineprof/custom_controller_helpers.rb b/lib/peek/rblineprof/custom_controller_helpers.rb index 9beb442bfa3..581cc6a37b4 100644 --- a/lib/peek/rblineprof/custom_controller_helpers.rb +++ b/lib/peek/rblineprof/custom_controller_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Peek module Rblineprof module CustomControllerHelpers @@ -41,7 +43,7 @@ module Peek ] end.sort_by{ |a,b,c,d,e,f| -f } - output = "<div class='modal-dialog modal-xl'><div class='modal-content'>" + output = ["<div class='modal-dialog modal-xl'><div class='modal-content'>"] output << "<div class='modal-header'>" output << "<h4>Line profiling: #{human_description(params[:lineprofiler])}</h4>" output << "<button class='close' type='button' data-dismiss='modal' aria-label='close'><span aria-hidden='true'>×</span></button>" @@ -93,7 +95,7 @@ module Peek output << "</div></div></div>" - response.body += "<div class='modal' id='modal-peek-line-profile' tabindex=-1>#{output}</div>".html_safe + response.body += "<div class='modal' id='modal-peek-line-profile' tabindex=-1>#{output.join}</div>".html_safe end ret diff --git a/lib/peek/views/gitaly.rb b/lib/peek/views/gitaly.rb index ab35f7a2258..860963ef94f 100644 --- a/lib/peek/views/gitaly.rb +++ b/lib/peek/views/gitaly.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Peek module Views class Gitaly < View diff --git a/lib/peek/views/host.rb b/lib/peek/views/host.rb index 43c8a35c7ea..b77355ea11b 100644 --- a/lib/peek/views/host.rb +++ b/lib/peek/views/host.rb @@ -1,8 +1,13 @@ +# frozen_string_literal: true + module Peek module Views class Host < View def results - { hostname: Gitlab::Environment.hostname } + { + hostname: Gitlab::Environment.hostname, + canary: Gitlab::Utils.to_boolean(ENV['CANARY']) + } end end end diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb index e877ab10248..e2a7d3ef5ba 100644 --- a/lib/rouge/formatters/html_gitlab.rb +++ b/lib/rouge/formatters/html_gitlab.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Rouge module Formatters class HTMLGitlab < Rouge::Formatters::HTML diff --git a/lib/rouge/plugins/common_mark.rb b/lib/rouge/plugins/common_mark.rb index 8f9de061124..d240df5a0e0 100644 --- a/lib/rouge/plugins/common_mark.rb +++ b/lib/rouge/plugins/common_mark.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # A rouge plugin for CommonMark markdown engine. # Used to highlight code generated by CommonMark. diff --git a/lib/rspec_flaky/config.rb b/lib/rspec_flaky/config.rb index 06e96f969f1..55c1d4747b4 100644 --- a/lib/rspec_flaky/config.rb +++ b/lib/rspec_flaky/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RspecFlaky class Config def self.generate_report? diff --git a/lib/rspec_flaky/example.rb b/lib/rspec_flaky/example.rb index b6e790cbbab..3c1b05257a0 100644 --- a/lib/rspec_flaky/example.rb +++ b/lib/rspec_flaky/example.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RspecFlaky # This is a wrapper class for RSpec::Core::Example class Example diff --git a/lib/rspec_flaky/flaky_example.rb b/lib/rspec_flaky/flaky_example.rb index 6be24014d89..da5dbf06bc9 100644 --- a/lib/rspec_flaky/flaky_example.rb +++ b/lib/rspec_flaky/flaky_example.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RspecFlaky # This represents a flaky RSpec example and is mainly meant to be saved in a JSON file class FlakyExample < OpenStruct diff --git a/lib/rspec_flaky/flaky_examples_collection.rb b/lib/rspec_flaky/flaky_examples_collection.rb index dea23c325be..290a51766e9 100644 --- a/lib/rspec_flaky/flaky_examples_collection.rb +++ b/lib/rspec_flaky/flaky_examples_collection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_support/hash_with_indifferent_access' require_relative 'flaky_example' diff --git a/lib/rspec_flaky/listener.rb b/lib/rspec_flaky/listener.rb index 9cd0c38cb55..19cc0baa2d3 100644 --- a/lib/rspec_flaky/listener.rb +++ b/lib/rspec_flaky/listener.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'json' require_dependency 'rspec_flaky/config' diff --git a/lib/rspec_flaky/report.rb b/lib/rspec_flaky/report.rb index 1c362fdd20d..9a0fb88c424 100644 --- a/lib/rspec_flaky/report.rb +++ b/lib/rspec_flaky/report.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'json' require 'time' diff --git a/lib/system_check/app/active_users_check.rb b/lib/system_check/app/active_users_check.rb index 1d72c8d6903..8446c2fc2c8 100644 --- a/lib/system_check/app/active_users_check.rb +++ b/lib/system_check/app/active_users_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class ActiveUsersCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/database_config_exists_check.rb b/lib/system_check/app/database_config_exists_check.rb index d1fae192350..1769145ed63 100644 --- a/lib/system_check/app/database_config_exists_check.rb +++ b/lib/system_check/app/database_config_exists_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class DatabaseConfigExistsCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/git_config_check.rb b/lib/system_check/app/git_config_check.rb index d08a81639e3..4e8d607096c 100644 --- a/lib/system_check/app/git_config_check.rb +++ b/lib/system_check/app/git_config_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class GitConfigCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/git_user_default_ssh_config_check.rb b/lib/system_check/app/git_user_default_ssh_config_check.rb index ad41760dff2..6cd53779bfd 100644 --- a/lib/system_check/app/git_user_default_ssh_config_check.rb +++ b/lib/system_check/app/git_user_default_ssh_config_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class GitUserDefaultSSHConfigCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/git_version_check.rb b/lib/system_check/app/git_version_check.rb index 44ec888c197..994af3ab53e 100644 --- a/lib/system_check/app/git_version_check.rb +++ b/lib/system_check/app/git_version_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class GitVersionCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/gitlab_config_exists_check.rb b/lib/system_check/app/gitlab_config_exists_check.rb index 247aa0994e4..1cc5ead0d89 100644 --- a/lib/system_check/app/gitlab_config_exists_check.rb +++ b/lib/system_check/app/gitlab_config_exists_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class GitlabConfigExistsCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/gitlab_config_up_to_date_check.rb b/lib/system_check/app/gitlab_config_up_to_date_check.rb index c609e48e133..58c7e3039c8 100644 --- a/lib/system_check/app/gitlab_config_up_to_date_check.rb +++ b/lib/system_check/app/gitlab_config_up_to_date_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class GitlabConfigUpToDateCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/init_script_exists_check.rb b/lib/system_check/app/init_script_exists_check.rb index d246e058e86..d36dbe7d67d 100644 --- a/lib/system_check/app/init_script_exists_check.rb +++ b/lib/system_check/app/init_script_exists_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class InitScriptExistsCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/init_script_up_to_date_check.rb b/lib/system_check/app/init_script_up_to_date_check.rb index 53a47eb0f42..569c41df6e4 100644 --- a/lib/system_check/app/init_script_up_to_date_check.rb +++ b/lib/system_check/app/init_script_up_to_date_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class InitScriptUpToDateCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/log_writable_check.rb b/lib/system_check/app/log_writable_check.rb index 3e0c436d6ee..e26ad143eb8 100644 --- a/lib/system_check/app/log_writable_check.rb +++ b/lib/system_check/app/log_writable_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class LogWritableCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/migrations_are_up_check.rb b/lib/system_check/app/migrations_are_up_check.rb index 5eedbacce77..b12e9ac6bba 100644 --- a/lib/system_check/app/migrations_are_up_check.rb +++ b/lib/system_check/app/migrations_are_up_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class MigrationsAreUpCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/orphaned_group_members_check.rb b/lib/system_check/app/orphaned_group_members_check.rb index 2b46d36fe51..3e6ffb8190b 100644 --- a/lib/system_check/app/orphaned_group_members_check.rb +++ b/lib/system_check/app/orphaned_group_members_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class OrphanedGroupMembersCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/projects_have_namespace_check.rb b/lib/system_check/app/projects_have_namespace_check.rb index a6ec9f7665c..2bf2529acf1 100644 --- a/lib/system_check/app/projects_have_namespace_check.rb +++ b/lib/system_check/app/projects_have_namespace_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class ProjectsHaveNamespaceCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/redis_version_check.rb b/lib/system_check/app/redis_version_check.rb index a0610e73576..890f8b44d13 100644 --- a/lib/system_check/app/redis_version_check.rb +++ b/lib/system_check/app/redis_version_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class RedisVersionCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/ruby_version_check.rb b/lib/system_check/app/ruby_version_check.rb index 57bbabece1f..d73c39f2c3f 100644 --- a/lib/system_check/app/ruby_version_check.rb +++ b/lib/system_check/app/ruby_version_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class RubyVersionCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/tmp_writable_check.rb b/lib/system_check/app/tmp_writable_check.rb index 99a75e57abf..6687df091d3 100644 --- a/lib/system_check/app/tmp_writable_check.rb +++ b/lib/system_check/app/tmp_writable_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class TmpWritableCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/uploads_directory_exists_check.rb b/lib/system_check/app/uploads_directory_exists_check.rb index 7026d0ba075..940eff9d4cf 100644 --- a/lib/system_check/app/uploads_directory_exists_check.rb +++ b/lib/system_check/app/uploads_directory_exists_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class UploadsDirectoryExistsCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/uploads_path_permission_check.rb b/lib/system_check/app/uploads_path_permission_check.rb index 7df6c060254..4a49f3bc2bb 100644 --- a/lib/system_check/app/uploads_path_permission_check.rb +++ b/lib/system_check/app/uploads_path_permission_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class UploadsPathPermissionCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/app/uploads_path_tmp_permission_check.rb b/lib/system_check/app/uploads_path_tmp_permission_check.rb index b276a81eac1..ae374f4707c 100644 --- a/lib/system_check/app/uploads_path_tmp_permission_check.rb +++ b/lib/system_check/app/uploads_path_tmp_permission_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module App class UploadsPathTmpPermissionCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/base_check.rb b/lib/system_check/base_check.rb index 0f5742dd67f..e06245294c4 100644 --- a/lib/system_check/base_check.rb +++ b/lib/system_check/base_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck # Base class for Checks. You must inherit from here # and implement the methods below when necessary diff --git a/lib/system_check/helpers.rb b/lib/system_check/helpers.rb index 6227e461d24..07d479848fe 100644 --- a/lib/system_check/helpers.rb +++ b/lib/system_check/helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module Helpers include ::Gitlab::TaskHelpers diff --git a/lib/system_check/incoming_email/foreman_configured_check.rb b/lib/system_check/incoming_email/foreman_configured_check.rb index 1db7bf2b782..944913087da 100644 --- a/lib/system_check/incoming_email/foreman_configured_check.rb +++ b/lib/system_check/incoming_email/foreman_configured_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module IncomingEmail class ForemanConfiguredCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/incoming_email/imap_authentication_check.rb b/lib/system_check/incoming_email/imap_authentication_check.rb index 3550c5796b0..613c2296375 100644 --- a/lib/system_check/incoming_email/imap_authentication_check.rb +++ b/lib/system_check/incoming_email/imap_authentication_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module IncomingEmail class ImapAuthenticationCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/incoming_email/initd_configured_check.rb b/lib/system_check/incoming_email/initd_configured_check.rb index ea23b8ef49c..acb4b5a9e74 100644 --- a/lib/system_check/incoming_email/initd_configured_check.rb +++ b/lib/system_check/incoming_email/initd_configured_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module IncomingEmail class InitdConfiguredCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/incoming_email/mail_room_running_check.rb b/lib/system_check/incoming_email/mail_room_running_check.rb index c1807501829..b7aead4624e 100644 --- a/lib/system_check/incoming_email/mail_room_running_check.rb +++ b/lib/system_check/incoming_email/mail_room_running_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module IncomingEmail class MailRoomRunningCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/orphans/namespace_check.rb b/lib/system_check/orphans/namespace_check.rb index 09b57c7b408..53b2d8fd5b3 100644 --- a/lib/system_check/orphans/namespace_check.rb +++ b/lib/system_check/orphans/namespace_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module Orphans class NamespaceCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb index 2695c658874..ef8fe945f61 100644 --- a/lib/system_check/orphans/repository_check.rb +++ b/lib/system_check/orphans/repository_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck module Orphans class RepositoryCheck < SystemCheck::BaseCheck diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb index 99c9e984107..11818ae54f8 100644 --- a/lib/system_check/simple_executor.rb +++ b/lib/system_check/simple_executor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SystemCheck # Simple Executor is current default executor for GitLab # It is a simple port from display logic in the old check.rake |
