Commit f88ff0cc authored by Douwe Maan's avatar Douwe Maan

Stylistic tweaks

parent 6f5cd03f
...@@ -42,7 +42,7 @@ module ExtractsPath ...@@ -42,7 +42,7 @@ module ExtractsPath
return pair unless @project return pair unless @project
if id =~ /^([[:alnum:]]{40})(.+)/ if id =~ /^(\h{40})(.+)/
# If the ref appears to be a SHA, we're done, just split the string # If the ref appears to be a SHA, we're done, just split the string
pair = $~.captures pair = $~.captures
else else
......
...@@ -27,6 +27,8 @@ module Gitlab ...@@ -27,6 +27,8 @@ module Gitlab
end end
end end
delegate :empty?, to: :children
def directory? def directory?
blank_node? || @path.end_with?('/') blank_node? || @path.end_with?('/')
end end
...@@ -91,8 +93,6 @@ module Gitlab ...@@ -91,8 +93,6 @@ module Gitlab
blank_node? || @entries.include?(@path) blank_node? || @entries.include?(@path)
end end
delegate :empty?, to: :children
def total_size def total_size
descendant_pattern = %r{^#{Regexp.escape(@path)}} descendant_pattern = %r{^#{Regexp.escape(@path)}}
entries.sum do |path, entry| entries.sum do |path, entry|
......
...@@ -31,6 +31,10 @@ module Gitlab ...@@ -31,6 +31,10 @@ module Gitlab
@attributes = Gitlab::Git::Attributes.new(path) @attributes = Gitlab::Git::Attributes.new(path)
end end
delegate :empty?,
:bare?,
to: :rugged
# Default branch in the repository # Default branch in the repository
def root_ref def root_ref
@root_ref ||= discover_default_branch @root_ref ||= discover_default_branch
...@@ -160,10 +164,6 @@ module Gitlab ...@@ -160,10 +164,6 @@ module Gitlab
!empty? !empty?
end end
delegate :empty?,
:bare?,
to: :rugged
def repo_exists? def repo_exists?
!!rugged !!rugged
end end
......
...@@ -12,12 +12,7 @@ module Gitlab ...@@ -12,12 +12,7 @@ module Gitlab
CONFIG_FILE = File.expand_path('../../config/resque.yml', __dir__) CONFIG_FILE = File.expand_path('../../config/resque.yml', __dir__)
class << self class << self
# Do NOT cache in an instance variable. Result may be mutated by caller. delegate :params, :url, to: :new
delegate :params, to: :new
# Do NOT cache in an instance variable. Result may be mutated by caller.
# @deprecated Use .params instead to get sentinel support
delegate :url, to: :new
def with def with
@pool ||= ConnectionPool.new(size: pool_size) { ::Redis.new(params) } @pool ||= ConnectionPool.new(size: pool_size) { ::Redis.new(params) }
......
...@@ -81,9 +81,9 @@ namespace :gemojione do ...@@ -81,9 +81,9 @@ namespace :gemojione do
# SpriteFactory's SCSS is a bit too verbose for our purposes here, so # SpriteFactory's SCSS is a bit too verbose for our purposes here, so
# let's simplify it # let's simplify it
system(%(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path})) system(%Q(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
system(%(sed -i '' "s/ no-repeat//" #{style_path})) system(%Q(sed -i '' "s/ no-repeat//" #{style_path}))
system(%(sed -i '' "s/ 0px/ 0/" #{style_path})) system(%Q(sed -i '' "s/ 0px/ 0/" #{style_path}))
# Append a generic rule that applies to all Emojis # Append a generic rule that applies to all Emojis
File.open(style_path, 'a') do |f| File.open(style_path, 'a') do |f|
......
...@@ -20,14 +20,19 @@ module Gitlab ...@@ -20,14 +20,19 @@ module Gitlab
# It has fallbacks to Debian, SuSE, OS X and systems running systemd. # It has fallbacks to Debian, SuSE, OS X and systems running systemd.
def os_name def os_name
os_name = run_command(%w(lsb_release -irs)) os_name = run_command(%w(lsb_release -irs))
os_name ||= File.read('/etc/system-release') if File.readable?('/etc/system-release')
os_name ||= "Debian #{File.read('/etc/debian_version')}" if File.readable?('/etc/debian_version')
os_name ||= File.read('/etc/SuSE-release') if File.readable?('/etc/SuSE-release')
os_name ||= os_name ||=
if os_x_version = run_command(%w(sw_vers -productVersion)) if File.readable?('/etc/system-release')
File.read('/etc/system-release')
elsif File.readable?('/etc/debian_version')
"Debian #{File.read('/etc/debian_version')}"
elsif File.readable?('/etc/SuSE-release')
File.read('/etc/SuSE-release')
elsif os_x_version = run_command(%w(sw_vers -productVersion))
"Mac OS X #{os_x_version}" "Mac OS X #{os_x_version}"
elsif File.readable?('/etc/os-release')
File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1]
end end
os_name ||= File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1] if File.readable?('/etc/os-release')
os_name.try(:squish!) os_name.try(:squish!)
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