Commit f012e934 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'resolve-lib-gitlab-differences' into 'master'

Move EE specific code out of lib/gitlab

See merge request gitlab-org/gitlab-ce!25741
parents 123841f6 3eee0426
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
end end
def model_name 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 end
end end
......
...@@ -11,7 +11,7 @@ module Gitlab ...@@ -11,7 +11,7 @@ module Gitlab
:trigger_request, :schedule, :merge_request, :trigger_request, :schedule, :merge_request,
:ignore_skip_ci, :save_incompleted, :ignore_skip_ci, :save_incompleted,
:seeds_block, :variables_attributes, :push_options, :seeds_block, :variables_attributes, :push_options,
:chat_data :chat_data, :allow_mirror_update
) do ) do
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
elsif Gitlab::Utils.to_boolean(ENV['CANARY']) elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
'favicon-yellow.png' 'favicon-yellow.png'
elsif Rails.env.development? elsif Rails.env.development?
'favicon-blue.png' development_favicon
else else
'favicon.png' 'favicon.png'
end end
...@@ -18,6 +18,12 @@ module Gitlab ...@@ -18,6 +18,12 @@ module Gitlab
ActionController::Base.helpers.image_path(image_name, host: host) ActionController::Base.helpers.image_path(image_name, host: host)
end 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) def status_overlay(status_name)
path = File.join( path = File.join(
'ci_favicons', 'ci_favicons',
......
...@@ -344,12 +344,12 @@ module Gitlab ...@@ -344,12 +344,12 @@ module Gitlab
end end
end end
def new_blobs(newrev) def new_blobs(newrev, dynamic_timeout: nil)
return [] if newrev.blank? || newrev == ::Gitlab::Git::BLANK_SHA return [] if newrev.blank? || newrev == ::Gitlab::Git::BLANK_SHA
strong_memoize("new_blobs_#{newrev}") do strong_memoize("new_blobs_#{newrev}") do
wrapped_gitaly_errors 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 end
end end
......
...@@ -84,15 +84,22 @@ module Gitlab ...@@ -84,15 +84,22 @@ module Gitlab
commits commits
end end
def list_new_blobs(newrev, limit = 0) def list_new_blobs(newrev, limit = 0, dynamic_timeout: nil)
request = Gitaly::ListNewBlobsRequest.new( request = Gitaly::ListNewBlobsRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
commit_id: newrev, commit_id: newrev,
limit: limit limit: limit
) )
timeout =
if dynamic_timeout
[dynamic_timeout, GitalyClient.medium_timeout].min
else
GitalyClient.medium_timeout
end
response = GitalyClient 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| response.flat_map do |msg|
# Returns an Array of Gitaly::NewBlobObject objects # Returns an Array of Gitaly::NewBlobObject objects
......
...@@ -48,7 +48,7 @@ module Gitlab ...@@ -48,7 +48,7 @@ module Gitlab
} }
issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes) issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
.merge!(attrs) .merge!(attrs)
end end
end end
end end
......
...@@ -55,7 +55,7 @@ module Gitlab ...@@ -55,7 +55,7 @@ module Gitlab
} }
merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes) merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
.merge!(attrs) .merge!(attrs)
end end
end end
end end
......
...@@ -48,7 +48,9 @@ module Gitlab ...@@ -48,7 +48,9 @@ module Gitlab
end end
def self.workers 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 end
def self.find_workers(root) def self.find_workers(root)
......
...@@ -11,7 +11,9 @@ module Gitlab ...@@ -11,7 +11,9 @@ module Gitlab
USERNAME_REGEXP = User.reference_pattern USERNAME_REGEXP = User.reference_pattern
def initialize(text) 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 end
def users def users
......
...@@ -104,6 +104,12 @@ module Gitlab ...@@ -104,6 +104,12 @@ module Gitlab
nil nil
end end
def try_megabytes_to_bytes(size)
Integer(size).megabytes
rescue ArgumentError
size
end
def bytes_to_megabytes(bytes) def bytes_to_megabytes(bytes)
bytes.to_f / Numeric::MEGABYTE bytes.to_f / Numeric::MEGABYTE
end end
......
...@@ -38,6 +38,18 @@ describe Gitlab::UserExtractor do ...@@ -38,6 +38,18 @@ describe Gitlab::UserExtractor do
expect(extractor.users).to include(user) expect(extractor.users).to include(user)
end 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 end
describe '#matches' do describe '#matches' do
......
...@@ -213,4 +213,22 @@ describe Gitlab::Utils do ...@@ -213,4 +213,22 @@ describe Gitlab::Utils do
expect(subject[:variables].first[:key]).to eq('VAR1') expect(subject[:variables].first[:key]).to eq('VAR1')
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment