Merge branch 'resolve-lib-gitlab-differences' into 'master'
Move EE specific code out of lib/gitlab See merge request gitlab-org/gitlab-ce!25741
This commit is contained in:
commit
f012e93482
|
@ -8,7 +8,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def model_name
|
||||
@model_name ||= ActiveModel::Name.new(self, nil, self.name.split("::").last)
|
||||
@model_name ||= ActiveModel::Name.new(self, nil, self.name.demodulize)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module Gitlab
|
|||
:trigger_request, :schedule, :merge_request,
|
||||
:ignore_skip_ci, :save_incompleted,
|
||||
:seeds_block, :variables_attributes, :push_options,
|
||||
:chat_data
|
||||
:chat_data, :allow_mirror_update
|
||||
) do
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Gitlab
|
|||
elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
|
||||
'favicon-yellow.png'
|
||||
elsif Rails.env.development?
|
||||
'favicon-blue.png'
|
||||
development_favicon
|
||||
else
|
||||
'favicon.png'
|
||||
end
|
||||
|
@ -18,6 +18,12 @@ module Gitlab
|
|||
ActionController::Base.helpers.image_path(image_name, host: host)
|
||||
end
|
||||
|
||||
def development_favicon
|
||||
# This is a separate method so that EE can return a different favicon
|
||||
# for development environments.
|
||||
'favicon-blue.png'
|
||||
end
|
||||
|
||||
def status_overlay(status_name)
|
||||
path = File.join(
|
||||
'ci_favicons',
|
||||
|
|
|
@ -344,12 +344,12 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
def new_blobs(newrev)
|
||||
def new_blobs(newrev, dynamic_timeout: nil)
|
||||
return [] if newrev.blank? || newrev == ::Gitlab::Git::BLANK_SHA
|
||||
|
||||
strong_memoize("new_blobs_#{newrev}") do
|
||||
wrapped_gitaly_errors do
|
||||
gitaly_ref_client.list_new_blobs(newrev, REV_LIST_COMMIT_LIMIT)
|
||||
gitaly_ref_client.list_new_blobs(newrev, REV_LIST_COMMIT_LIMIT, dynamic_timeout: dynamic_timeout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,15 +84,22 @@ module Gitlab
|
|||
commits
|
||||
end
|
||||
|
||||
def list_new_blobs(newrev, limit = 0)
|
||||
def list_new_blobs(newrev, limit = 0, dynamic_timeout: nil)
|
||||
request = Gitaly::ListNewBlobsRequest.new(
|
||||
repository: @gitaly_repo,
|
||||
commit_id: newrev,
|
||||
limit: limit
|
||||
)
|
||||
|
||||
timeout =
|
||||
if dynamic_timeout
|
||||
[dynamic_timeout, GitalyClient.medium_timeout].min
|
||||
else
|
||||
GitalyClient.medium_timeout
|
||||
end
|
||||
|
||||
response = GitalyClient
|
||||
.call(@storage, :ref_service, :list_new_blobs, request, timeout: GitalyClient.medium_timeout)
|
||||
.call(@storage, :ref_service, :list_new_blobs, request, timeout: timeout)
|
||||
|
||||
response.flat_map do |msg|
|
||||
# Returns an Array of Gitaly::NewBlobObject objects
|
||||
|
|
|
@ -48,7 +48,7 @@ module Gitlab
|
|||
}
|
||||
|
||||
issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
|
||||
.merge!(attrs)
|
||||
.merge!(attrs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,7 +55,7 @@ module Gitlab
|
|||
}
|
||||
|
||||
merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
|
||||
.merge!(attrs)
|
||||
.merge!(attrs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,7 +48,9 @@ module Gitlab
|
|||
end
|
||||
|
||||
def self.workers
|
||||
@workers ||= find_workers(Rails.root.join('app', 'workers'))
|
||||
@workers ||=
|
||||
find_workers(Rails.root.join('app', 'workers')) +
|
||||
find_workers(Rails.root.join('ee', 'app', 'workers'))
|
||||
end
|
||||
|
||||
def self.find_workers(root)
|
||||
|
|
|
@ -11,7 +11,9 @@ module Gitlab
|
|||
USERNAME_REGEXP = User.reference_pattern
|
||||
|
||||
def initialize(text)
|
||||
@text = text
|
||||
# EE passes an Array to `text` in a few places, so we want to support both
|
||||
# here.
|
||||
@text = Array(text).join(' ')
|
||||
end
|
||||
|
||||
def users
|
||||
|
|
|
@ -104,6 +104,12 @@ module Gitlab
|
|||
nil
|
||||
end
|
||||
|
||||
def try_megabytes_to_bytes(size)
|
||||
Integer(size).megabytes
|
||||
rescue ArgumentError
|
||||
size
|
||||
end
|
||||
|
||||
def bytes_to_megabytes(bytes)
|
||||
bytes.to_f / Numeric::MEGABYTE
|
||||
end
|
||||
|
|
|
@ -38,6 +38,18 @@ describe Gitlab::UserExtractor do
|
|||
|
||||
expect(extractor.users).to include(user)
|
||||
end
|
||||
|
||||
context 'input as array of strings' do
|
||||
it 'is treated as one string' do
|
||||
extractor = described_class.new(text.lines)
|
||||
|
||||
user_1 = create(:user, username: "USER-1")
|
||||
user_4 = create(:user, username: "USER-4")
|
||||
user_email = create(:user, email: 'user@gitlab.org')
|
||||
|
||||
expect(extractor.users).to contain_exactly(user_1, user_4, user_email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#matches' do
|
||||
|
|
|
@ -213,4 +213,22 @@ describe Gitlab::Utils do
|
|||
expect(subject[:variables].first[:key]).to eq('VAR1')
|
||||
end
|
||||
end
|
||||
|
||||
describe '.try_megabytes_to_bytes' do
|
||||
context 'when the size can be converted to megabytes' do
|
||||
it 'returns the size in megabytes' do
|
||||
size = described_class.try_megabytes_to_bytes(1)
|
||||
|
||||
expect(size).to eq(1.megabytes)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the size can not be converted to megabytes' do
|
||||
it 'returns the input size' do
|
||||
size = described_class.try_megabytes_to_bytes('foo')
|
||||
|
||||
expect(size).to eq('foo')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue