Commit 46015c15 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-rename-run-helper' into 'master'

Rename `run` task helper method to prevent conflict with StateMachine

This prevents the following message from appearing whenever running a
Rake task:

    Instance method "run" is already defined in Object, use generic
    helper instead or set StateMachines::Machine.ignore_method_conflicts
    = true.

See merge request !5750
parents 480535a1 12e93d6f
...@@ -46,7 +46,7 @@ namespace :gitlab do ...@@ -46,7 +46,7 @@ namespace :gitlab do
} }
correct_options = options.map do |name, value| correct_options = options.map do |name, value|
run(%W(#{Gitlab.config.git.bin_path} config --global --get #{name})).try(:squish) == value run_command(%W(#{Gitlab.config.git.bin_path} config --global --get #{name})).try(:squish) == value
end end
if correct_options.all? if correct_options.all?
...@@ -316,7 +316,7 @@ namespace :gitlab do ...@@ -316,7 +316,7 @@ namespace :gitlab do
min_redis_version = "2.8.0" min_redis_version = "2.8.0"
print "Redis version >= #{min_redis_version}? ... " print "Redis version >= #{min_redis_version}? ... "
redis_version = run(%W(redis-cli --version)) redis_version = run_command(%W(redis-cli --version))
redis_version = redis_version.try(:match, /redis-cli (\d+\.\d+\.\d+)/) redis_version = redis_version.try(:match, /redis-cli (\d+\.\d+\.\d+)/)
if redis_version && if redis_version &&
(Gem::Version.new(redis_version[1]) > Gem::Version.new(min_redis_version)) (Gem::Version.new(redis_version[1]) > Gem::Version.new(min_redis_version))
...@@ -893,7 +893,7 @@ namespace :gitlab do ...@@ -893,7 +893,7 @@ namespace :gitlab do
def check_ruby_version def check_ruby_version
required_version = Gitlab::VersionInfo.new(2, 1, 0) required_version = Gitlab::VersionInfo.new(2, 1, 0)
current_version = Gitlab::VersionInfo.parse(run(%W(ruby --version))) current_version = Gitlab::VersionInfo.parse(run_command(%W(ruby --version)))
print "Ruby version >= #{required_version} ? ... " print "Ruby version >= #{required_version} ? ... "
...@@ -910,7 +910,7 @@ namespace :gitlab do ...@@ -910,7 +910,7 @@ namespace :gitlab do
def check_git_version def check_git_version
required_version = Gitlab::VersionInfo.new(2, 7, 3) required_version = Gitlab::VersionInfo.new(2, 7, 3)
current_version = Gitlab::VersionInfo.parse(run(%W(#{Gitlab.config.git.bin_path} --version))) current_version = Gitlab::VersionInfo.parse(run_command(%W(#{Gitlab.config.git.bin_path} --version)))
puts "Your git bin path is \"#{Gitlab.config.git.bin_path}\"" puts "Your git bin path is \"#{Gitlab.config.git.bin_path}\""
print "Git version >= #{required_version} ? ... " print "Git version >= #{required_version} ? ... "
......
...@@ -8,7 +8,7 @@ namespace :gitlab do ...@@ -8,7 +8,7 @@ namespace :gitlab do
# check Ruby version # check Ruby version
ruby_version = run_and_match(%W(ruby --version), /[\d\.p]+/).try(:to_s) ruby_version = run_and_match(%W(ruby --version), /[\d\.p]+/).try(:to_s)
# check Gem version # check Gem version
gem_version = run(%W(gem --version)) gem_version = run_command(%W(gem --version))
# check Bundler version # check Bundler version
bunder_version = run_and_match(%W(bundle --version), /[\d\.]+/).try(:to_s) bunder_version = run_and_match(%W(bundle --version), /[\d\.]+/).try(:to_s)
# check Bundler version # check Bundler version
...@@ -17,7 +17,7 @@ namespace :gitlab do ...@@ -17,7 +17,7 @@ namespace :gitlab do
puts "" puts ""
puts "System information".color(:yellow) puts "System information".color(:yellow)
puts "System:\t\t#{os_name || "unknown".color(:red)}" puts "System:\t\t#{os_name || "unknown".color(:red)}"
puts "Current User:\t#{run(%W(whoami))}" puts "Current User:\t#{run_command(%W(whoami))}"
puts "Using RVM:\t#{rvm_version.present? ? "yes".color(:green) : "no"}" puts "Using RVM:\t#{rvm_version.present? ? "yes".color(:green) : "no"}"
puts "RVM Version:\t#{rvm_version}" if rvm_version.present? puts "RVM Version:\t#{rvm_version}" if rvm_version.present?
puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}" puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
......
...@@ -23,7 +23,7 @@ namespace :gitlab do ...@@ -23,7 +23,7 @@ namespace :gitlab do
# It will primarily use lsb_relase to determine the OS. # It will primarily use lsb_relase to determine the OS.
# 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(%W(lsb_release -irs)) os_name = run_command(%W(lsb_release -irs))
os_name ||= if File.readable?('/etc/system-release') os_name ||= if File.readable?('/etc/system-release')
File.read('/etc/system-release') File.read('/etc/system-release')
end end
...@@ -34,7 +34,7 @@ namespace :gitlab do ...@@ -34,7 +34,7 @@ namespace :gitlab do
os_name ||= if File.readable?('/etc/SuSE-release') os_name ||= if File.readable?('/etc/SuSE-release')
File.read('/etc/SuSE-release') File.read('/etc/SuSE-release')
end end
os_name ||= if os_x_version = run(%W(sw_vers -productVersion)) os_name ||= if os_x_version = run_command(%W(sw_vers -productVersion))
"Mac OS X #{os_x_version}" "Mac OS X #{os_x_version}"
end end
os_name ||= if File.readable?('/etc/os-release') os_name ||= if File.readable?('/etc/os-release')
...@@ -62,10 +62,10 @@ namespace :gitlab do ...@@ -62,10 +62,10 @@ namespace :gitlab do
# Returns nil if nothing matched # Returns nil if nothing matched
# Returns the MatchData if the pattern matched # Returns the MatchData if the pattern matched
# #
# see also #run # see also #run_command
# see also String#match # see also String#match
def run_and_match(command, regexp) def run_and_match(command, regexp)
run(command).try(:match, regexp) run_command(command).try(:match, regexp)
end end
# Runs the given command # Runs the given command
...@@ -74,7 +74,7 @@ namespace :gitlab do ...@@ -74,7 +74,7 @@ namespace :gitlab do
# Returns the output of the command otherwise # Returns the output of the command otherwise
# #
# see also #run_and_match # see also #run_and_match
def run(command) def run_command(command)
output, _ = Gitlab::Popen.popen(command) output, _ = Gitlab::Popen.popen(command)
output output
rescue Errno::ENOENT rescue Errno::ENOENT
...@@ -82,7 +82,7 @@ namespace :gitlab do ...@@ -82,7 +82,7 @@ namespace :gitlab do
end end
def uid_for(user_name) def uid_for(user_name)
run(%W(id -u #{user_name})).chomp.to_i run_command(%W(id -u #{user_name})).chomp.to_i
end end
def gid_for(group_name) def gid_for(group_name)
...@@ -96,7 +96,7 @@ namespace :gitlab do ...@@ -96,7 +96,7 @@ namespace :gitlab do
def warn_user_is_not_gitlab def warn_user_is_not_gitlab
unless @warned_user_not_gitlab unless @warned_user_not_gitlab
gitlab_user = Gitlab.config.gitlab.user gitlab_user = Gitlab.config.gitlab.user
current_user = run(%W(whoami)).chomp current_user = run_command(%W(whoami)).chomp
unless current_user == gitlab_user unless current_user == gitlab_user
puts " Warning ".color(:black).background(:yellow) puts " Warning ".color(:black).background(:yellow)
puts " You are running as user #{current_user.color(:magenta)}, we hope you know what you are doing." puts " You are running as user #{current_user.color(:magenta)}, we hope you know what you are doing."
......
...@@ -34,17 +34,15 @@ task :spinach do ...@@ -34,17 +34,15 @@ task :spinach do
run_spinach_tests(nil) run_spinach_tests(nil)
end end
def run_command(cmd) def run_system_command(cmd)
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd)
end end
def run_spinach_command(args) def run_spinach_command(args)
run_command(%w(spinach -r rerun) + args) run_system_command(%w(spinach -r rerun) + args)
end end
def run_spinach_tests(tags) def run_spinach_tests(tags)
#run_command(%w(rake gitlab:setup)) or raise('gitlab:setup failed!')
success = run_spinach_command(%W(--tags #{tags})) success = run_spinach_command(%W(--tags #{tags}))
3.times do |_| 3.times do |_|
break if success break if success
......
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