Commit 87c9df29 authored by Douwe Maan's avatar Douwe Maan

Don’t exclude some file in lib from rubocop

parent e2bbbb1a
...@@ -22,13 +22,6 @@ AllCops: ...@@ -22,13 +22,6 @@ AllCops:
- 'db/fixtures/**/*' - 'db/fixtures/**/*'
- 'tmp/**/*' - 'tmp/**/*'
- 'bin/**/*' - 'bin/**/*'
- 'lib/backup/**/*'
- 'lib/ci/backup/**/*'
- 'lib/tasks/**/*'
- 'lib/ci/migrate/**/*'
- 'lib/email_validator.rb'
- 'lib/gitlab/upgrader.rb'
- 'lib/gitlab/seeder.rb'
- 'generator_templates/**/*' - 'generator_templates/**/*'
# Style ####################################################################### # Style #######################################################################
...@@ -208,6 +201,9 @@ Style/FrozenStringLiteralComment: ...@@ -208,6 +201,9 @@ Style/FrozenStringLiteralComment:
# Do not introduce global variables. # Do not introduce global variables.
Style/GlobalVars: Style/GlobalVars:
Enabled: true Enabled: true
Exclude:
- 'lib/backup/**/*'
- 'lib/tasks/**/*'
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }` # Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`. # over 1.8 syntax `{ :a => 1, :b => 2 }`.
...@@ -780,6 +776,11 @@ Rails/HasAndBelongsToMany: ...@@ -780,6 +776,11 @@ Rails/HasAndBelongsToMany:
# Checks for calls to puts, print, etc. # Checks for calls to puts, print, etc.
Rails/Output: Rails/Output:
Enabled: true Enabled: true
Exclude:
- lib/gitlab/seeder.rb
- lib/gitlab/upgrader.rb
- 'lib/backup/**/*'
- 'lib/tasks/**/*'
# Checks for incorrect grammar when using methods like `3.day.ago`. # Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar: Rails/PluralizationGrammar:
...@@ -971,3 +972,9 @@ Style/ConditionalAssignment: ...@@ -971,3 +972,9 @@ Style/ConditionalAssignment:
Style/DoubleNegation: Style/DoubleNegation:
Enabled: false Enabled: false
Rails/Exit:
Enabled: true
Exclude:
- lib/gitlab/upgrader.rb
- 'lib/backup/**/*'
...@@ -5,7 +5,7 @@ module Backup ...@@ -5,7 +5,7 @@ module Backup
attr_reader :config, :db_file_name attr_reader :config, :db_file_name
def initialize def initialize
@config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env] @config = YAML.load_file(File.join(Rails.root, 'config', 'database.yml'))[Rails.env]
@db_file_name = File.join(Gitlab.config.backup.path, 'db', 'database.sql.gz') @db_file_name = File.join(Gitlab.config.backup.path, 'db', 'database.sql.gz')
end end
...@@ -13,28 +13,32 @@ module Backup ...@@ -13,28 +13,32 @@ module Backup
FileUtils.mkdir_p(File.dirname(db_file_name)) FileUtils.mkdir_p(File.dirname(db_file_name))
FileUtils.rm_f(db_file_name) FileUtils.rm_f(db_file_name)
compress_rd, compress_wr = IO.pipe compress_rd, compress_wr = IO.pipe
compress_pid = spawn(*%W(gzip -1 -c), in: compress_rd, out: [db_file_name, 'w', 0600]) compress_pid = spawn(*%w(gzip -1 -c), in: compress_rd, out: [db_file_name, 'w', 0600])
compress_rd.close compress_rd.close
dump_pid = case config["adapter"] dump_pid =
when /^mysql/ then case config["adapter"]
$progress.print "Dumping MySQL database #{config['database']} ... " when /^mysql/ then
# Workaround warnings from MySQL 5.6 about passwords on cmd line $progress.print "Dumping MySQL database #{config['database']} ... "
ENV['MYSQL_PWD'] = config["password"].to_s if config["password"] # Workaround warnings from MySQL 5.6 about passwords on cmd line
spawn('mysqldump', *mysql_args, config['database'], out: compress_wr) ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
when "postgresql" then spawn('mysqldump', *mysql_args, config['database'], out: compress_wr)
$progress.print "Dumping PostgreSQL database #{config['database']} ... " when "postgresql" then
pg_env $progress.print "Dumping PostgreSQL database #{config['database']} ... "
pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump. pg_env
if Gitlab.config.backup.pg_schema pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
pgsql_args << "-n" if Gitlab.config.backup.pg_schema
pgsql_args << Gitlab.config.backup.pg_schema pgsql_args << "-n"
pgsql_args << Gitlab.config.backup.pg_schema
end
spawn('pg_dump', *pgsql_args, config['database'], out: compress_wr)
end end
spawn('pg_dump', *pgsql_args, config['database'], out: compress_wr)
end
compress_wr.close compress_wr.close
success = [compress_pid, dump_pid].all? { |pid| Process.waitpid(pid); $?.success? } success = [compress_pid, dump_pid].all? do |pid|
Process.waitpid(pid)
$?.success?
end
report_success(success) report_success(success)
abort 'Backup failed' unless success abort 'Backup failed' unless success
...@@ -42,23 +46,27 @@ module Backup ...@@ -42,23 +46,27 @@ module Backup
def restore def restore
decompress_rd, decompress_wr = IO.pipe decompress_rd, decompress_wr = IO.pipe
decompress_pid = spawn(*%W(gzip -cd), out: decompress_wr, in: db_file_name) decompress_pid = spawn(*%w(gzip -cd), out: decompress_wr, in: db_file_name)
decompress_wr.close decompress_wr.close
restore_pid = case config["adapter"] restore_pid =
when /^mysql/ then case config["adapter"]
$progress.print "Restoring MySQL database #{config['database']} ... " when /^mysql/ then
# Workaround warnings from MySQL 5.6 about passwords on cmd line $progress.print "Restoring MySQL database #{config['database']} ... "
ENV['MYSQL_PWD'] = config["password"].to_s if config["password"] # Workaround warnings from MySQL 5.6 about passwords on cmd line
spawn('mysql', *mysql_args, config['database'], in: decompress_rd) ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
when "postgresql" then spawn('mysql', *mysql_args, config['database'], in: decompress_rd)
$progress.print "Restoring PostgreSQL database #{config['database']} ... " when "postgresql" then
pg_env $progress.print "Restoring PostgreSQL database #{config['database']} ... "
spawn('psql', config['database'], in: decompress_rd) pg_env
end spawn('psql', config['database'], in: decompress_rd)
end
decompress_rd.close decompress_rd.close
success = [decompress_pid, restore_pid].all? { |pid| Process.waitpid(pid); $?.success? } success = [decompress_pid, restore_pid].all? do |pid|
Process.waitpid(pid)
$?.success?
end
report_success(success) report_success(success)
abort 'Restore failed' unless success abort 'Restore failed' unless success
......
...@@ -26,10 +26,10 @@ module Backup ...@@ -26,10 +26,10 @@ module Backup
abort 'Backup failed' abort 'Backup failed'
end end
run_pipeline!([%W(tar -C #{@backup_files_dir} -cf - .), %W(gzip -c -1)], out: [backup_tarball, 'w', 0600]) run_pipeline!([%W(tar -C #{@backup_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
FileUtils.rm_rf(@backup_files_dir) FileUtils.rm_rf(@backup_files_dir)
else else
run_pipeline!([%W(tar -C #{app_files_dir} -cf - .), %W(gzip -c -1)], out: [backup_tarball, 'w', 0600]) run_pipeline!([%W(tar -C #{app_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
end end
end end
...@@ -37,7 +37,7 @@ module Backup ...@@ -37,7 +37,7 @@ module Backup
backup_existing_files_dir backup_existing_files_dir
create_files_dir create_files_dir
run_pipeline!([%W(gzip -cd), %W(tar -C #{app_files_dir} -xf -)], in: backup_tarball) run_pipeline!([%w(gzip -cd), %W(tar -C #{app_files_dir} -xf -)], in: backup_tarball)
end end
def backup_existing_files_dir def backup_existing_files_dir
...@@ -47,7 +47,7 @@ module Backup ...@@ -47,7 +47,7 @@ module Backup
end end
end end
def run_pipeline!(cmd_list, options={}) def run_pipeline!(cmd_list, options = {})
status_list = Open3.pipeline(*cmd_list, options) status_list = Open3.pipeline(*cmd_list, options)
abort 'Backup failed' unless status_list.compact.all?(&:success?) abort 'Backup failed' unless status_list.compact.all?(&:success?)
end end
......
module Backup module Backup
class Manager class Manager
ARCHIVES_TO_BACKUP = %w[uploads builds artifacts pages lfs registry] ARCHIVES_TO_BACKUP = %w[uploads builds artifacts pages lfs registry].freeze
FOLDERS_TO_BACKUP = %w[repositories db] FOLDERS_TO_BACKUP = %w[repositories db].freeze
FILE_NAME_SUFFIX = '_gitlab_backup.tar' FILE_NAME_SUFFIX = '_gitlab_backup.tar'.freeze
def pack def pack
# Make sure there is a connection # Make sure there is a connection
...@@ -20,13 +20,13 @@ module Backup ...@@ -20,13 +20,13 @@ module Backup
Dir.chdir(Gitlab.config.backup.path) do Dir.chdir(Gitlab.config.backup.path) do
File.open("#{Gitlab.config.backup.path}/backup_information.yml", File.open("#{Gitlab.config.backup.path}/backup_information.yml",
"w+") do |file| "w+") do |file|
file << s.to_yaml.gsub(/^---\n/,'') file << s.to_yaml.gsub(/^---\n/, '')
end end
# create archive # create archive
$progress.print "Creating backup archive: #{tar_file} ... " $progress.print "Creating backup archive: #{tar_file} ... "
# Set file permissions on open to prevent chmod races. # Set file permissions on open to prevent chmod races.
tar_system_options = {out: [tar_file, 'w', Gitlab.config.backup.archive_permissions]} tar_system_options = { out: [tar_file, 'w', Gitlab.config.backup.archive_permissions] }
if Kernel.system('tar', '-cf', '-', *backup_contents, tar_system_options) if Kernel.system('tar', '-cf', '-', *backup_contents, tar_system_options)
$progress.puts "done".color(:green) $progress.puts "done".color(:green)
else else
...@@ -50,8 +50,8 @@ module Backup ...@@ -50,8 +50,8 @@ module Backup
directory = connect_to_remote_directory(connection_settings) directory = connect_to_remote_directory(connection_settings)
if directory.files.create(key: tar_file, body: File.open(tar_file), public: false, if directory.files.create(key: tar_file, body: File.open(tar_file), public: false,
multipart_chunk_size: Gitlab.config.backup.upload.multipart_chunk_size, multipart_chunk_size: Gitlab.config.backup.upload.multipart_chunk_size,
encryption: Gitlab.config.backup.upload.encryption) encryption: Gitlab.config.backup.upload.encryption)
$progress.puts "done".color(:green) $progress.puts "done".color(:green)
else else
puts "uploading backup to #{remote_directory} failed".color(:red) puts "uploading backup to #{remote_directory} failed".color(:red)
...@@ -123,11 +123,11 @@ module Backup ...@@ -123,11 +123,11 @@ module Backup
exit 1 exit 1
end end
if ENV['BACKUP'].present? tar_file = if ENV['BACKUP'].present?
tar_file = "#{ENV['BACKUP']}#{FILE_NAME_SUFFIX}" "#{ENV['BACKUP']}#{FILE_NAME_SUFFIX}"
else else
tar_file = file_list.first file_list.first
end end
unless File.exist?(tar_file) unless File.exist?(tar_file)
$progress.puts "The backup file #{tar_file} does not exist!" $progress.puts "The backup file #{tar_file} does not exist!"
...@@ -158,7 +158,7 @@ module Backup ...@@ -158,7 +158,7 @@ module Backup
end end
def tar_version def tar_version
tar_version, _ = Gitlab::Popen.popen(%W(tar --version)) tar_version, _ = Gitlab::Popen.popen(%w(tar --version))
tar_version.force_encoding('locale').split("\n").first tar_version.force_encoding('locale').split("\n").first
end end
......
...@@ -2,7 +2,7 @@ require 'yaml' ...@@ -2,7 +2,7 @@ require 'yaml'
module Backup module Backup
class Repository class Repository
# rubocop:disable Metrics/AbcSize
def dump def dump
prepare prepare
...@@ -85,11 +85,11 @@ module Backup ...@@ -85,11 +85,11 @@ module Backup
project.ensure_dir_exist project.ensure_dir_exist
if File.exists?(path_to_project_bundle) cmd = if File.exist?(path_to_project_bundle)
cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_project_bundle} #{path_to_project_repo}) %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_project_bundle} #{path_to_project_repo})
else else
cmd = %W(#{Gitlab.config.git.bin_path} init --bare #{path_to_project_repo}) %W(#{Gitlab.config.git.bin_path} init --bare #{path_to_project_repo})
end end
output, status = Gitlab::Popen.popen(cmd) output, status = Gitlab::Popen.popen(cmd)
if status.zero? if status.zero?
...@@ -150,6 +150,7 @@ module Backup ...@@ -150,6 +150,7 @@ module Backup
puts output puts output
end end
end end
# rubocop:enable Metrics/AbcSize
protected protected
...@@ -193,7 +194,7 @@ module Backup ...@@ -193,7 +194,7 @@ module Backup
end end
def silent def silent
{err: '/dev/null', out: '/dev/null'} { err: '/dev/null', out: '/dev/null' }
end end
private private
......
...@@ -2,7 +2,6 @@ require 'backup/files' ...@@ -2,7 +2,6 @@ require 'backup/files'
module Backup module Backup
class Uploads < Files class Uploads < Files
def initialize def initialize
super('uploads', Rails.root.join('public/uploads')) super('uploads', Rails.root.join('public/uploads'))
end end
......
...@@ -18,7 +18,7 @@ def Notify.deliver_later ...@@ -18,7 +18,7 @@ def Notify.deliver_later
self self
end end
eos eos
eval(code) eval(code) # rubocop:disable Lint/Eval
end end
end end
end end
...@@ -46,7 +46,7 @@ module Gitlab ...@@ -46,7 +46,7 @@ module Gitlab
git_tags = fetch_git_tags git_tags = fetch_git_tags
git_tags = git_tags.select { |version| version =~ /v\d+\.\d+\.\d+\Z/ } git_tags = git_tags.select { |version| version =~ /v\d+\.\d+\.\d+\Z/ }
git_versions = git_tags.map { |tag| Gitlab::VersionInfo.parse(tag.match(/v\d+\.\d+\.\d+/).to_s) } git_versions = git_tags.map { |tag| Gitlab::VersionInfo.parse(tag.match(/v\d+\.\d+\.\d+/).to_s) }
"v#{git_versions.sort.last.to_s}" "v#{git_versions.sort.last}"
end end
def fetch_git_tags def fetch_git_tags
...@@ -59,10 +59,10 @@ module Gitlab ...@@ -59,10 +59,10 @@ module Gitlab
"Stash changed files" => %W(#{Gitlab.config.git.bin_path} stash), "Stash changed files" => %W(#{Gitlab.config.git.bin_path} stash),
"Get latest code" => %W(#{Gitlab.config.git.bin_path} fetch), "Get latest code" => %W(#{Gitlab.config.git.bin_path} fetch),
"Switch to new version" => %W(#{Gitlab.config.git.bin_path} checkout v#{latest_version}), "Switch to new version" => %W(#{Gitlab.config.git.bin_path} checkout v#{latest_version}),
"Install gems" => %W(bundle), "Install gems" => %w(bundle),
"Migrate DB" => %W(bundle exec rake db:migrate), "Migrate DB" => %w(bundle exec rake db:migrate),
"Recompile assets" => %W(bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile), "Recompile assets" => %w(bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile),
"Clear cache" => %W(bundle exec rake cache:clear) "Clear cache" => %w(bundle exec rake cache:clear)
} }
end end
......
...@@ -2,7 +2,7 @@ desc 'Security check via brakeman' ...@@ -2,7 +2,7 @@ desc 'Security check via brakeman'
task :brakeman do task :brakeman do
# We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge # We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge
# requests are welcome! # requests are welcome!
if system(*%W(brakeman --no-progress --skip-files lib/backup/repository.rb -w3 -z)) if system(*%w(brakeman --no-progress --skip-files lib/backup/repository.rb -w3 -z))
puts 'Security check succeed' puts 'Security check succeed'
else else
puts 'Security check failed' puts 'Security check failed'
......
namespace :cache do namespace :cache do
namespace :clear do namespace :clear do
REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000 REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000
REDIS_SCAN_START_STOP = '0' # Magic value, see http://redis.io/commands/scan REDIS_SCAN_START_STOP = '0'.freeze # Magic value, see http://redis.io/commands/scan
desc "GitLab | Clear redis cache" desc "GitLab | Clear redis cache"
task redis: :environment do task redis: :environment do
......
...@@ -2,7 +2,7 @@ task dev: ["dev:setup"] ...@@ -2,7 +2,7 @@ task dev: ["dev:setup"]
namespace :dev do namespace :dev do
desc "GitLab | Setup developer environment (db, fixtures)" desc "GitLab | Setup developer environment (db, fixtures)"
task :setup => :environment do task setup: :environment do
ENV['force'] = 'yes' ENV['force'] = 'yes'
Rake::Task["gitlab:setup"].invoke Rake::Task["gitlab:setup"].invoke
Rake::Task["gitlab:shell:setup"].invoke Rake::Task["gitlab:shell:setup"].invoke
......
desc 'Checks if migrations in a branch require downtime' desc 'Checks if migrations in a branch require downtime'
task downtime_check: :environment do task downtime_check: :environment do
if defined?(Gitlab::License) repo = if defined?(Gitlab::License)
repo = 'gitlab-ee' 'gitlab-ee'
else else
repo = 'gitlab-ce' 'gitlab-ce'
end end
`git fetch https://gitlab.com/gitlab-org/#{repo}.git --depth 1` `git fetch https://gitlab.com/gitlab-org/#{repo}.git --depth 1`
......
desc 'Code duplication analyze via flay' desc 'Code duplication analyze via flay'
task :flay do task :flay do
output = %x(bundle exec flay --mass 35 app/ lib/gitlab/) output = `bundle exec flay --mass 35 app/ lib/gitlab/`
if output.include? "Similar code found" if output.include? "Similar code found"
puts output puts output
......
...@@ -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(%Q(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path})) system(%(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
system(%Q(sed -i '' "s/ no-repeat//" #{style_path})) system(%(sed -i '' "s/ no-repeat//" #{style_path}))
system(%Q(sed -i '' "s/ 0px/ 0/" #{style_path})) system(%(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,7 +20,7 @@ namespace :gitlab do ...@@ -20,7 +20,7 @@ namespace :gitlab do
desc 'GitLab | Assets | Fix all absolute url references in CSS' desc 'GitLab | Assets | Fix all absolute url references in CSS'
task :fix_urls do task :fix_urls do
css_files = Dir['public/assets/*.css'] css_files = Dir['public/assets/*.css']
css_files.each do | file | css_files.each do |file|
# replace url(/assets/*) with url(./*) # replace url(/assets/*) with url(./*)
puts "Fixing #{file}" puts "Fixing #{file}"
system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file
......
...@@ -6,8 +6,6 @@ namespace :gitlab do ...@@ -6,8 +6,6 @@ namespace :gitlab do
gitlab:ldap:check gitlab:ldap:check
gitlab:app:check} gitlab:app:check}
namespace :app do namespace :app do
desc "GitLab | Check the configuration of the GitLab Rails app" desc "GitLab | Check the configuration of the GitLab Rails app"
task check: :environment do task check: :environment do
...@@ -34,7 +32,6 @@ namespace :gitlab do ...@@ -34,7 +32,6 @@ namespace :gitlab do
finished_checking "GitLab" finished_checking "GitLab"
end end
# Checks # Checks
######################## ########################
...@@ -194,7 +191,7 @@ namespace :gitlab do ...@@ -194,7 +191,7 @@ namespace :gitlab do
def check_migrations_are_up def check_migrations_are_up
print "All migrations up? ... " print "All migrations up? ... "
migration_status, _ = Gitlab::Popen.popen(%W(bundle exec rake db:migrate:status)) migration_status, _ = Gitlab::Popen.popen(%w(bundle exec rake db:migrate:status))
unless migration_status =~ /down\s+\d{14}/ unless migration_status =~ /down\s+\d{14}/
puts "yes".color(:green) puts "yes".color(:green)
...@@ -279,7 +276,7 @@ namespace :gitlab do ...@@ -279,7 +276,7 @@ namespace :gitlab do
upload_path_tmp = File.join(upload_path, 'tmp') upload_path_tmp = File.join(upload_path, 'tmp')
if File.stat(upload_path).mode == 040700 if File.stat(upload_path).mode == 040700
unless Dir.exists?(upload_path_tmp) unless Dir.exist?(upload_path_tmp)
puts 'skipped (no tmp uploads folder yet)'.color(:magenta) puts 'skipped (no tmp uploads folder yet)'.color(:magenta)
return return
end end
...@@ -316,7 +313,7 @@ namespace :gitlab do ...@@ -316,7 +313,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_command(%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))
...@@ -351,7 +348,6 @@ namespace :gitlab do ...@@ -351,7 +348,6 @@ namespace :gitlab do
finished_checking "GitLab Shell" finished_checking "GitLab Shell"
end end
# Checks # Checks
######################## ########################
...@@ -387,7 +383,7 @@ namespace :gitlab do ...@@ -387,7 +383,7 @@ namespace :gitlab do
unless File.exist?(repo_base_path) unless File.exist?(repo_base_path)
puts "can't check because of previous errors".color(:magenta) puts "can't check because of previous errors".color(:magenta)
return break
end end
unless File.symlink?(repo_base_path) unless File.symlink?(repo_base_path)
...@@ -410,7 +406,7 @@ namespace :gitlab do ...@@ -410,7 +406,7 @@ namespace :gitlab do
unless File.exist?(repo_base_path) unless File.exist?(repo_base_path)
puts "can't check because of previous errors".color(:magenta) puts "can't check because of previous errors".color(:magenta)
return break
end end
if File.stat(repo_base_path).mode.to_s(8).ends_with?("2770") if File.stat(repo_base_path).mode.to_s(8).ends_with?("2770")
...@@ -440,7 +436,7 @@ namespace :gitlab do ...@@ -440,7 +436,7 @@ namespace :gitlab do
unless File.exist?(repo_base_path) unless File.exist?(repo_base_path)
puts "can't check because of previous errors".color(:magenta) puts "can't check because of previous errors".color(:magenta)
return break
end end
uid = uid_for(gitlab_shell_ssh_user) uid = uid_for(gitlab_shell_ssh_user)
...@@ -493,7 +489,6 @@ namespace :gitlab do ...@@ -493,7 +489,6 @@ namespace :gitlab do
) )
fix_and_rerun fix_and_rerun
end end
end end
end end
...@@ -565,8 +560,6 @@ namespace :gitlab do ...@@ -565,8 +560,6 @@ namespace :gitlab do
end end
end end
namespace :sidekiq do namespace :sidekiq do
desc "GitLab | Check the configuration of Sidekiq" desc "GitLab | Check the configuration of Sidekiq"
task check: :environment do task check: :environment do
...@@ -579,7 +572,6 @@ namespace :gitlab do ...@@ -579,7 +572,6 @@ namespace :gitlab do
finished_checking "Sidekiq" finished_checking "Sidekiq"
end end
# Checks # Checks
######################## ########################
...@@ -621,12 +613,11 @@ namespace :gitlab do ...@@ -621,12 +613,11 @@ namespace :gitlab do
end end
def sidekiq_process_count def sidekiq_process_count
ps_ux, _ = Gitlab::Popen.popen(%W(ps ux)) ps_ux, _ = Gitlab::Popen.popen(%w(ps ux))
ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count
end end
end end
namespace :incoming_email do namespace :incoming_email do
desc "GitLab | Check the configuration of Reply by email" desc "GitLab | Check the configuration of Reply by email"
task check: :environment do task check: :environment do
...@@ -649,7 +640,6 @@ namespace :gitlab do ...@@ -649,7 +640,6 @@ namespace :gitlab do
finished_checking "Reply by email" finished_checking "Reply by email"
end end
# Checks # Checks
######################## ########################
...@@ -757,7 +747,7 @@ namespace :gitlab do ...@@ -757,7 +747,7 @@ namespace :gitlab do
end end
def mail_room_running? def mail_room_running?
ps_ux, _ = Gitlab::Popen.popen(%W(ps ux)) ps_ux, _ = Gitlab::Popen.popen(%w(ps ux))
ps_ux.include?("mail_room") ps_ux.include?("mail_room")
end end
end end
...@@ -805,13 +795,13 @@ namespace :gitlab do ...@@ -805,13 +795,13 @@ namespace :gitlab do
def check_ldap_auth(adapter) def check_ldap_auth(adapter)
auth = adapter.config.has_auth? auth = adapter.config.has_auth?
if auth && adapter.ldap.bind message = if auth && adapter.ldap.bind
message = 'Success'.color(:green) 'Success'.color(:green)
elsif auth elsif auth
message = 'Failed. Check `bind_dn` and `password` configuration values'.color(:red) 'Failed. Check `bind_dn` and `password` configuration values'.color(:red)
else else
message = 'Anonymous. No `bind_dn` or `password` configured'.color(:yellow) 'Anonymous. No `bind_dn` or `password` configured'.color(:yellow)
end end
puts "LDAP authentication... #{message}" puts "LDAP authentication... #{message}"
end end
...@@ -838,11 +828,11 @@ namespace :gitlab do ...@@ -838,11 +828,11 @@ namespace :gitlab do
user = User.find_by(username: username) user = User.find_by(username: username)
if user if user
repo_dirs = user.authorized_projects.map do |p| repo_dirs = user.authorized_projects.map do |p|
File.join( File.join(
p.repository_storage_path, p.repository_storage_path,
"#{p.path_with_namespace}.git" "#{p.path_with_namespace}.git"
) )
end end
repo_dirs.each { |repo_dir| check_repo_integrity(repo_dir) } repo_dirs.each { |repo_dir| check_repo_integrity(repo_dir) }
else else
...@@ -855,7 +845,7 @@ namespace :gitlab do ...@@ -855,7 +845,7 @@ namespace :gitlab do
########################## ##########################
def fix_and_rerun def fix_and_rerun
puts " Please #{"fix the error above"} and rerun the checks.".color(:red) puts " Please fix the error above and rerun the checks.".color(:red)
end end
def for_more_information(*sources) def for_more_information(*sources)
...@@ -917,7 +907,7 @@ namespace :gitlab do ...@@ -917,7 +907,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_command(%W(ruby --version))) current_version = Gitlab::VersionInfo.parse(run_command(%w(ruby --version)))
print "Ruby version >= #{required_version} ? ... " print "Ruby version >= #{required_version} ? ... "
...@@ -988,13 +978,13 @@ namespace :gitlab do ...@@ -988,13 +978,13 @@ namespace :gitlab do
end end
def check_config_lock(repo_dir) def check_config_lock(repo_dir)
config_exists = File.exist?(File.join(repo_dir,'config.lock')) config_exists = File.exist?(File.join(repo_dir, 'config.lock'))
config_output = config_exists ? 'yes'.color(:red) : 'no'.color(:green) config_output = config_exists ? 'yes'.color(:red) : 'no'.color(:green)
puts "'config.lock' file exists?".color(:yellow) + " ... #{config_output}" puts "'config.lock' file exists?".color(:yellow) + " ... #{config_output}"
end end
def check_ref_locks(repo_dir) def check_ref_locks(repo_dir)
lock_files = Dir.glob(File.join(repo_dir,'refs/heads/*.lock')) lock_files = Dir.glob(File.join(repo_dir, 'refs/heads/*.lock'))
if lock_files.present? if lock_files.present?
puts "Ref lock files exist:".color(:red) puts "Ref lock files exist:".color(:red)
lock_files.each do |lock_file| lock_files.each do |lock_file|
......
...@@ -25,7 +25,6 @@ namespace :gitlab do ...@@ -25,7 +25,6 @@ namespace :gitlab do
end end
all_dirs.each do |dir_path| all_dirs.each do |dir_path|
if remove_flag if remove_flag
if FileUtils.rm_rf dir_path if FileUtils.rm_rf dir_path
puts "Removed...#{dir_path}".color(:red) puts "Removed...#{dir_path}".color(:red)
...@@ -53,11 +52,11 @@ namespace :gitlab do ...@@ -53,11 +52,11 @@ namespace :gitlab do
IO.popen(%W(find #{repo_root} -mindepth 1 -maxdepth 2 -name *.git)) do |find| IO.popen(%W(find #{repo_root} -mindepth 1 -maxdepth 2 -name *.git)) do |find|
find.each_line do |path| find.each_line do |path|
path.chomp! path.chomp!
repo_with_namespace = path. repo_with_namespace = path
sub(repo_root, ''). .sub(repo_root, '')
sub(%r{^/*}, ''). .sub(%r{^/*}, '')
chomp('.git'). .chomp('.git')
chomp('.wiki') .chomp('.wiki')
next if Project.find_by_full_path(repo_with_namespace) next if Project.find_by_full_path(repo_with_namespace)
new_path = path + move_suffix new_path = path + move_suffix
puts path.inspect + ' -> ' + new_path.inspect puts path.inspect + ' -> ' + new_path.inspect
......
...@@ -23,7 +23,7 @@ namespace :gitlab do ...@@ -23,7 +23,7 @@ namespace :gitlab do
end end
desc 'Drop all tables' desc 'Drop all tables'
task :drop_tables => :environment do task drop_tables: :environment do
connection = ActiveRecord::Base.connection connection = ActiveRecord::Base.connection
# If MySQL, turn off foreign key checks # If MySQL, turn off foreign key checks
...@@ -62,9 +62,9 @@ namespace :gitlab do ...@@ -62,9 +62,9 @@ namespace :gitlab do
ref = Shellwords.escape(args[:ref]) ref = Shellwords.escape(args[:ref])
migrations = `git diff #{ref}.. --name-only -- db/migrate`.lines. migrations = `git diff #{ref}.. --name-only -- db/migrate`.lines
map { |file| Rails.root.join(file.strip).to_s }. .map { |file| Rails.root.join(file.strip).to_s }
select { |file| File.file?(file) } .select { |file| File.file?(file) }
Gitlab::DowntimeCheck.new.check_and_print(migrations) Gitlab::DowntimeCheck.new.check_and_print(migrations)
end end
......
namespace :gitlab do namespace :gitlab do
namespace :git do namespace :git do
desc "GitLab | Git | Repack" desc "GitLab | Git | Repack"
task repack: :environment do task repack: :environment do
failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} repack -a --quiet), "Repacking repo") failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} repack -a --quiet), "Repacking repo")
...@@ -50,6 +49,5 @@ namespace :gitlab do ...@@ -50,6 +49,5 @@ namespace :gitlab do
puts "The following repositories reported errors:".color(:red) puts "The following repositories reported errors:".color(:red)
failures.each { |f| puts "- #{f}" } failures.each { |f| puts "- #{f}" }
end end
end end
end end
...@@ -46,7 +46,7 @@ namespace :gitlab do ...@@ -46,7 +46,7 @@ namespace :gitlab do
group = Namespace.find_by(path: group_name) group = Namespace.find_by(path: group_name)
# create group namespace # create group namespace
unless group unless group
group = Group.new(:name => group_name) group = Group.new(name: group_name)
group.path = group_name group.path = group_name
group.owner = user group.owner = user
if group.save if group.save
......
...@@ -7,7 +7,7 @@ namespace :gitlab do ...@@ -7,7 +7,7 @@ namespace :gitlab do
desc "GitLab | Display exported DB structure" desc "GitLab | Display exported DB structure"
task data: :environment do task data: :environment do
puts YAML.load_file(Gitlab::ImportExport.config_file)['project_tree'].to_yaml(:SortKeys => true) puts YAML.load_file(Gitlab::ImportExport.config_file)['project_tree'].to_yaml(SortKeys: true)
end end
end end
end end
...@@ -2,24 +2,23 @@ namespace :gitlab do ...@@ -2,24 +2,23 @@ namespace :gitlab do
namespace :env do namespace :env do
desc "GitLab | Show information about GitLab and its environment" desc "GitLab | Show information about GitLab and its environment"
task info: :environment do task info: :environment do
# check if there is an RVM environment # check if there is an RVM environment
rvm_version = run_and_match(%W(rvm --version), /[\d\.]+/).try(:to_s) rvm_version = run_and_match(%w(rvm --version), /[\d\.]+/).try(:to_s)
# 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_command(%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 Rake version # check Rake version
rake_version = run_and_match(%W(rake --version), /[\d\.]+/).try(:to_s) rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s)
# check redis version # check redis version
redis_version = run_and_match(%W(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a
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_command(%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)}"
...@@ -29,7 +28,6 @@ namespace :gitlab do ...@@ -29,7 +28,6 @@ namespace :gitlab do
puts "Redis Version:\t#{redis_version[1] || "unknown".color(:red)}" puts "Redis Version:\t#{redis_version[1] || "unknown".color(:red)}"
puts "Sidekiq Version:#{Sidekiq::VERSION}" puts "Sidekiq Version:#{Sidekiq::VERSION}"
# check database adapter # check database adapter
database_adapter = ActiveRecord::Base.connection.adapter_name.downcase database_adapter = ActiveRecord::Base.connection.adapter_name.downcase
...@@ -54,8 +52,6 @@ namespace :gitlab do ...@@ -54,8 +52,6 @@ namespace :gitlab do
puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".color(:green) : "no"}" puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".color(:green) : "no"}"
puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab.config.omniauth.enabled puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab.config.omniauth.enabled
# check Gitolite version # check Gitolite version
gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.hooks_path}/../VERSION" gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.hooks_path}/../VERSION"
if File.readable?(gitlab_shell_version_file) if File.readable?(gitlab_shell_version_file)
...@@ -71,7 +67,6 @@ namespace :gitlab do ...@@ -71,7 +67,6 @@ namespace :gitlab do
end end
puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}" puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
puts "Git:\t\t#{Gitlab.config.git.bin_path}" puts "Git:\t\t#{Gitlab.config.git.bin_path}"
end end
end end
end end
...@@ -20,10 +20,10 @@ namespace :gitlab do ...@@ -20,10 +20,10 @@ namespace :gitlab do
config = { config = {
user: Gitlab.config.gitlab.user, user: Gitlab.config.gitlab.user,
gitlab_url: gitlab_url, gitlab_url: gitlab_url,
http_settings: {self_signed_cert: false}.stringify_keys, http_settings: { self_signed_cert: false }.stringify_keys,
auth_file: File.join(user_home, ".ssh", "authorized_keys"), auth_file: File.join(user_home, ".ssh", "authorized_keys"),
redis: { redis: {
bin: %x{which redis-cli}.chomp, bin: `which redis-cli`.chomp,
namespace: "resque:gitlab" namespace: "resque:gitlab"
}.stringify_keys, }.stringify_keys,
log_level: "INFO", log_level: "INFO",
...@@ -43,7 +43,7 @@ namespace :gitlab do ...@@ -43,7 +43,7 @@ namespace :gitlab do
File.open("config.yml", "w+") {|f| f.puts config.to_yaml} File.open("config.yml", "w+") {|f| f.puts config.to_yaml}
# Launch installation process # Launch installation process
system(*%W(bin/install) + repository_storage_paths_args) system(*%w(bin/install) + repository_storage_paths_args)
end end
# (Re)create hooks # (Re)create hooks
......
namespace :gitlab do namespace :gitlab do
namespace :sidekiq do namespace :sidekiq do
QUEUE = 'queue:post_receive' QUEUE = 'queue:post_receive'.freeze
desc 'Drop all Sidekiq PostReceive jobs for a given project' desc 'Drop all Sidekiq PostReceive jobs for a given project'
task :drop_post_receive , [:project] => :environment do |t, args| task :drop_post_receive, [:project] => :environment do |t, args|
unless args.project.present? unless args.project.present?
abort "Please specify the project you want to drop PostReceive jobs for:\n rake gitlab:sidekiq:drop_post_receive[group/project]" abort "Please specify the project you want to drop PostReceive jobs for:\n rake gitlab:sidekiq:drop_post_receive[group/project]"
end end
...@@ -21,7 +21,7 @@ namespace :gitlab do ...@@ -21,7 +21,7 @@ namespace :gitlab do
# new jobs already. We will repopulate it with the old jobs, skipping the # new jobs already. We will repopulate it with the old jobs, skipping the
# ones we want to drop. # ones we want to drop.
dropped = 0 dropped = 0
while (job = redis.lpop(temp_queue)) do while (job = redis.lpop(temp_queue))
if repo_path(job) == project_path if repo_path(job) == project_path
dropped += 1 dropped += 1
else else
......
...@@ -19,23 +19,15 @@ module Gitlab ...@@ -19,23 +19,15 @@ module Gitlab
# 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_command(%W(lsb_release -irs)) os_name = run_command(%w(lsb_release -irs))
os_name ||= if File.readable?('/etc/system-release') os_name ||= File.read('/etc/system-release') if File.readable?('/etc/system-release')
File.read('/etc/system-release') os_name ||= "Debian #{File.read('/etc/debian_version')}" if File.readable?('/etc/debian_version')
end os_name ||= File.read('/etc/SuSE-release') if File.readable?('/etc/SuSE-release')
os_name ||= if File.readable?('/etc/debian_version') os_name ||=
debian_version = File.read('/etc/debian_version') if os_x_version = run_command(%w(sw_vers -productVersion))
"Debian #{debian_version}" "Mac OS X #{os_x_version}"
end end
os_name ||= if File.readable?('/etc/SuSE-release') os_name ||= File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1] if File.readable?('/etc/os-release')
File.read('/etc/SuSE-release')
end
os_name ||= if os_x_version = run_command(%W(sw_vers -productVersion))
"Mac OS X #{os_x_version}"
end
os_name ||= if File.readable?('/etc/os-release')
File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1]
end
os_name.try(:squish!) os_name.try(:squish!)
end end
...@@ -104,7 +96,7 @@ module Gitlab ...@@ -104,7 +96,7 @@ module Gitlab
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_command(%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."
...@@ -171,14 +163,14 @@ module Gitlab ...@@ -171,14 +163,14 @@ module Gitlab
def reset_to_tag(tag_wanted, target_dir) def reset_to_tag(tag_wanted, target_dir)
tag = tag =
begin begin
# First try to checkout without fetching # First try to checkout without fetching
# to avoid stalling tests if the Internet is down. # to avoid stalling tests if the Internet is down.
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} describe -- #{tag_wanted}]) run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} describe -- #{tag_wanted}])
rescue Gitlab::TaskFailedError rescue Gitlab::TaskFailedError
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} fetch origin]) run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} fetch origin])
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} describe -- origin/#{tag_wanted}]) run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} describe -- origin/#{tag_wanted}])
end end
if tag if tag
run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} reset --hard #{tag.strip}]) run_command!(%W[#{Gitlab.config.git.bin_path} -C #{target_dir} reset --hard #{tag.strip}])
......
...@@ -2,15 +2,15 @@ namespace :gitlab do ...@@ -2,15 +2,15 @@ namespace :gitlab do
desc "GitLab | Run all tests" desc "GitLab | Run all tests"
task :test do task :test do
cmds = [ cmds = [
%W(rake brakeman), %w(rake brakeman),
%W(rake rubocop), %w(rake rubocop),
%W(rake spinach), %w(rake spinach),
%W(rake spec), %w(rake spec),
%W(rake karma) %w(rake karma)
] ]
cmds.each do |cmd| cmds.each do |cmd|
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) or raise("#{cmd} failed!") system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
end end
end end
end end
namespace :gitlab do namespace :gitlab do
desc 'GitLab | Tracks a deployment in GitLab Performance Monitoring' desc 'GitLab | Tracks a deployment in GitLab Performance Monitoring'
task track_deployment: :environment do task track_deployment: :environment do
metric = Gitlab::Metrics::Metric. metric = Gitlab::Metrics::Metric
new('deployments', version: Gitlab::VERSION) .new('deployments', version: Gitlab::VERSION)
Gitlab::Metrics.submit_metrics([metric.to_hash]) Gitlab::Metrics.submit_metrics([metric.to_hash])
end end
......
...@@ -46,7 +46,7 @@ namespace :gitlab do ...@@ -46,7 +46,7 @@ namespace :gitlab do
"https://gitlab.com/gitlab-org/gitlab-ci-yml.git", "https://gitlab.com/gitlab-org/gitlab-ci-yml.git",
/(\.{1,2}|LICENSE|Pages|autodeploy|\.gitlab-ci.yml)\z/ /(\.{1,2}|LICENSE|Pages|autodeploy|\.gitlab-ci.yml)\z/
) )
] ].freeze
def vendor_directory def vendor_directory
Rails.root.join('vendor') Rails.root.join('vendor')
......
namespace :gitlab do namespace :gitlab do
namespace :web_hook do namespace :web_hook do
desc "GitLab | Adds a webhook to the projects" desc "GitLab | Adds a webhook to the projects"
task :add => :environment do task add: :environment do
web_hook_url = ENV['URL'] web_hook_url = ENV['URL']
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
...@@ -21,7 +21,7 @@ namespace :gitlab do ...@@ -21,7 +21,7 @@ namespace :gitlab do
end end
desc "GitLab | Remove a webhook from the projects" desc "GitLab | Remove a webhook from the projects"
task :rm => :environment do task rm: :environment do
web_hook_url = ENV['URL'] web_hook_url = ENV['URL']
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
...@@ -34,7 +34,7 @@ namespace :gitlab do ...@@ -34,7 +34,7 @@ namespace :gitlab do
end end
desc "GitLab | List webhooks" desc "GitLab | List webhooks"
task :list => :environment do task list: :environment do
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
projects = find_projects(namespace_path) projects = find_projects(namespace_path)
......
...@@ -6,4 +6,3 @@ unless Rails.env.production? ...@@ -6,4 +6,3 @@ unless Rails.env.production?
end end
end end
end end
...@@ -24,7 +24,7 @@ task migrate_iids: :environment do ...@@ -24,7 +24,7 @@ task migrate_iids: :environment do
else else
print 'F' print 'F'
end end
rescue => ex rescue
print 'F' print 'F'
end end
end end
......
...@@ -76,23 +76,23 @@ namespace :services do ...@@ -76,23 +76,23 @@ namespace :services do
end end
param_hash param_hash
end.sort_by { |p| p[:required] ? 0 : 1 } end
service_hash[:params].sort_by! { |p| p[:required] ? 0 : 1 }
puts "Collected data for: #{service.title}, #{Time.now-service_start}" puts "Collected data for: #{service.title}, #{Time.now - service_start}"
service_hash service_hash
end end
doc_start = Time.now doc_start = Time.now
doc_path = File.join(Rails.root, 'doc', 'api', 'services.md') doc_path = File.join(Rails.root, 'doc', 'api', 'services.md')
result = ERB.new(services_template, 0 , '>') result = ERB.new(services_template, 0, '>')
.result(OpenStruct.new(services: services).instance_eval { binding }) .result(OpenStruct.new(services: services).instance_eval { binding })
File.open(doc_path, 'w') do |f| File.open(doc_path, 'w') do |f|
f.write result f.write result
end end
puts "write a new service.md to: #{doc_path.to_s}, #{Time.now-doc_start}" puts "write a new service.md to: #{doc_path}, #{Time.now - doc_start}"
end end
end end
namespace :sidekiq do namespace :sidekiq do
desc "GitLab | Stop sidekiq" desc "GitLab | Stop sidekiq"
task :stop do task :stop do
system *%W(bin/background_jobs stop) system(*%w(bin/background_jobs stop))
end end
desc "GitLab | Start sidekiq" desc "GitLab | Start sidekiq"
task :start do task :start do
system *%W(bin/background_jobs start) system(*%w(bin/background_jobs start))
end end
desc 'GitLab | Restart sidekiq' desc 'GitLab | Restart sidekiq'
task :restart do task :restart do
system *%W(bin/background_jobs restart) system(*%w(bin/background_jobs restart))
end end
desc "GitLab | Start sidekiq with launchd on Mac OS X" desc "GitLab | Start sidekiq with launchd on Mac OS X"
task :launchd do task :launchd do
system *%W(bin/background_jobs start_no_deamonize) system(*%w(bin/background_jobs start_no_deamonize))
end end
end end
...@@ -4,8 +4,8 @@ namespace :spec do ...@@ -4,8 +4,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run request specs' desc 'GitLab | Rspec | Run request specs'
task :api do task :api do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag @api) %w(rspec spec --tag @api)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -13,8 +13,8 @@ namespace :spec do ...@@ -13,8 +13,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run feature specs' desc 'GitLab | Rspec | Run feature specs'
task :feature do task :feature do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag @feature) %w(rspec spec --tag @feature)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -22,8 +22,8 @@ namespace :spec do ...@@ -22,8 +22,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run model specs' desc 'GitLab | Rspec | Run model specs'
task :models do task :models do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag @models) %w(rspec spec --tag @models)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -31,8 +31,8 @@ namespace :spec do ...@@ -31,8 +31,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run service specs' desc 'GitLab | Rspec | Run service specs'
task :services do task :services do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag @services) %w(rspec spec --tag @services)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -40,8 +40,8 @@ namespace :spec do ...@@ -40,8 +40,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run lib specs' desc 'GitLab | Rspec | Run lib specs'
task :lib do task :lib do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag @lib) %w(rspec spec --tag @lib)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -49,8 +49,8 @@ namespace :spec do ...@@ -49,8 +49,8 @@ namespace :spec do
desc 'GitLab | Rspec | Run other specs' desc 'GitLab | Rspec | Run other specs'
task :other do task :other do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services) %w(rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services)
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -59,14 +59,14 @@ end ...@@ -59,14 +59,14 @@ end
desc "GitLab | Run specs" desc "GitLab | Run specs"
task :spec do task :spec do
cmds = [ cmds = [
%W(rake gitlab:setup), %w(rake gitlab:setup),
%W(rspec spec), %w(rspec spec),
] ]
run_commands(cmds) run_commands(cmds)
end end
def run_commands(cmds) def run_commands(cmds)
cmds.each do |cmd| cmds.each do |cmd|
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) or raise("#{cmd} failed!") system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
end end
end end
...@@ -35,7 +35,7 @@ task :spinach do ...@@ -35,7 +35,7 @@ task :spinach do
end end
def run_system_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)
......
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