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-06-07 12:10:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-07 12:10:26 +0300
commitf4c6fbb86fbec3e5917e317b3490232d98531881 (patch)
treea2648b816d6be98456303f4059e342fe850c6c7e /lib
parent362b615a84bf303d5b5b1c3168d6592fb4306d9d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/commits.rb5
-rw-r--r--lib/api/entities/commit.rb1
-rw-r--r--lib/gitlab/ci/badge/coverage/template.rb16
-rw-r--r--lib/gitlab/ci/badge/pipeline/template.rb16
-rw-r--r--lib/gitlab/ci/badge/template.rb13
-rw-r--r--lib/gitlab/database/load_balancing/sidekiq_server_middleware.rb5
-rw-r--r--lib/gitlab/gitaly_client.rb2
-rw-r--r--lib/gitlab/gitaly_client/storage_settings.rb2
-rw-r--r--lib/tasks/gitlab/gitaly.rake2
-rw-r--r--lib/tasks/gitlab/helpers.rake4
10 files changed, 22 insertions, 44 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 72d4f3db571..541a37b0abe 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-
require 'mime/types'
module API
@@ -41,6 +40,7 @@ module API
optional :with_stats, type: Boolean, desc: 'Stats about each commit will be added to the response'
optional :first_parent, type: Boolean, desc: 'Only include the first parent of merges'
optional :order, type: String, desc: 'List commits in order', default: 'default', values: %w[default topo]
+ optional :trailers, type: Boolean, desc: 'Parse and include Git trailers for every commit', default: false
use :pagination
end
get ':id/repository/commits' do
@@ -62,7 +62,8 @@ module API
after: after,
all: all,
first_parent: first_parent,
- order: order)
+ order: order,
+ trailers: params[:trailers])
serializer = with_stats ? Entities::CommitWithStats : Entities::Commit
diff --git a/lib/api/entities/commit.rb b/lib/api/entities/commit.rb
index 3eaf896f1ac..fd23c23b980 100644
--- a/lib/api/entities/commit.rb
+++ b/lib/api/entities/commit.rb
@@ -9,6 +9,7 @@ module API
expose :safe_message, as: :message
expose :author_name, :author_email, :authored_date
expose :committer_name, :committer_email, :committed_date
+ expose :trailers
expose :web_url do |commit, _options|
Gitlab::UrlBuilder.build(commit)
diff --git a/lib/gitlab/ci/badge/coverage/template.rb b/lib/gitlab/ci/badge/coverage/template.rb
index 7589fa5ff8b..96702420e9d 100644
--- a/lib/gitlab/ci/badge/coverage/template.rb
+++ b/lib/gitlab/ci/badge/coverage/template.rb
@@ -24,26 +24,10 @@ module Gitlab::Ci
@key_width = badge.customization.dig(:key_width)
end
- def key_text
- if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
- @key_text
- else
- @entity.to_s
- end
- end
-
def value_text
@status ? ("%.2f%%" % @status) : 'unknown'
end
- def key_width
- if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
- @key_width
- else
- 62
- end
- end
-
def value_width
@status ? 54 : 58
end
diff --git a/lib/gitlab/ci/badge/pipeline/template.rb b/lib/gitlab/ci/badge/pipeline/template.rb
index 8430b01fc9a..c39f96e4a34 100644
--- a/lib/gitlab/ci/badge/pipeline/template.rb
+++ b/lib/gitlab/ci/badge/pipeline/template.rb
@@ -28,26 +28,10 @@ module Gitlab::Ci
@key_width = badge.customization.dig(:key_width)
end
- def key_text
- if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
- @key_text
- else
- @entity.to_s
- end
- end
-
def value_text
STATUS_RENAME[@status.to_s] || @status.to_s
end
- def key_width
- if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
- @key_width
- else
- 62
- end
- end
-
def value_width
54
end
diff --git a/lib/gitlab/ci/badge/template.rb b/lib/gitlab/ci/badge/template.rb
index 0580dad72ba..d514a8577bd 100644
--- a/lib/gitlab/ci/badge/template.rb
+++ b/lib/gitlab/ci/badge/template.rb
@@ -8,6 +8,7 @@ module Gitlab::Ci
class Template
MAX_KEY_TEXT_SIZE = 64
MAX_KEY_WIDTH = 512
+ DEFAULT_KEY_WIDTH = 62
def initialize(badge)
@entity = badge.entity
@@ -15,7 +16,11 @@ module Gitlab::Ci
end
def key_text
- raise NotImplementedError
+ if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
+ @key_text
+ else
+ @entity.to_s
+ end
end
def value_text
@@ -23,7 +28,11 @@ module Gitlab::Ci
end
def key_width
- raise NotImplementedError
+ if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
+ @key_width
+ else
+ DEFAULT_KEY_WIDTH
+ end
end
def value_width
diff --git a/lib/gitlab/database/load_balancing/sidekiq_server_middleware.rb b/lib/gitlab/database/load_balancing/sidekiq_server_middleware.rb
index 1c243f31809..3f0d39b811f 100644
--- a/lib/gitlab/database/load_balancing/sidekiq_server_middleware.rb
+++ b/lib/gitlab/database/load_balancing/sidekiq_server_middleware.rb
@@ -32,10 +32,13 @@ module Gitlab
return true unless location
+ job_data_consistency = worker_class.get_data_consistency
+ job[:data_consistency] = job_data_consistency.to_s
+
if replica_caught_up?(location)
job[:database_chosen] = 'replica'
false
- elsif worker_class.get_data_consistency == :delayed && not_yet_retried?(job)
+ elsif job_data_consistency == :delayed && not_yet_retried?(job)
job[:database_chosen] = 'retry'
raise JobReplicaNotUpToDate, "Sidekiq job #{worker_class} JID-#{job['jid']} couldn't use the replica."\
" Replica was not up to date."
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 2c26da037da..f4a89edecd1 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -120,7 +120,7 @@ module Gitlab
raise "storage #{storage.inspect} is missing a gitaly_address"
end
- unless %w(tcp unix tls).include?(URI(address).scheme)
+ unless URI(address).scheme.in?(%w(tcp unix tls))
raise "Unsupported Gitaly address: #{address.inspect} does not use URL scheme 'tcp' or 'unix' or 'tls'"
end
diff --git a/lib/gitlab/gitaly_client/storage_settings.rb b/lib/gitlab/gitaly_client/storage_settings.rb
index 4cc0269673f..f66dc3010ea 100644
--- a/lib/gitlab/gitaly_client/storage_settings.rb
+++ b/lib/gitlab/gitaly_client/storage_settings.rb
@@ -52,7 +52,7 @@ module Gitlab
@legacy_disk_path = File.expand_path(storage['path'], Rails.root) if storage['path']
storage['path'] = Deprecated
- @hash = ActiveSupport::HashWithIndifferentAccess.new(storage)
+ @hash = storage.with_indifferent_access
end
def gitaly_address
diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake
index cafa06e2a67..df75b3cf716 100644
--- a/lib/tasks/gitlab/gitaly.rake
+++ b/lib/tasks/gitlab/gitaly.rake
@@ -3,7 +3,7 @@
namespace :gitlab do
namespace :gitaly do
desc 'GitLab | Gitaly | Install or upgrade gitaly'
- task :install, [:dir, :storage_path, :repo] => :with_gitlab_helpers do |t, args|
+ task :install, [:dir, :storage_path, :repo] => :gitlab_environment do |t, args|
warn_user_is_not_gitlab
unless args.dir.present? && args.storage_path.present?
diff --git a/lib/tasks/gitlab/helpers.rake b/lib/tasks/gitlab/helpers.rake
index 220a333fbd6..b61b1833c5a 100644
--- a/lib/tasks/gitlab/helpers.rake
+++ b/lib/tasks/gitlab/helpers.rake
@@ -6,7 +6,3 @@ StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
task gitlab_environment: :environment do
extend SystemCheck::Helpers
end
-
-task :with_gitlab_helpers do
- extend SystemCheck::Helpers
-end