BigW Consortium Gitlab

Commit aac5b78d by Rémy Coutable

Merge branch 'remove-colorize' into 'master'

Replace colorize gem with rainbow. ## What does this MR do? It replaces the [colorize](https://github.com/fazibear/colorize) gem with [rainbow](https://github.com/sickill/rainbow). ## Are there points in the code the reviewer needs to double check? Make sure all relevant modified rake tasks still work. I checked repeatedly using `git grep 'color'` that all uses of any `.color` method were replaced by their Rainbow equivalent, you'll want to double check. We (should have, at least) [only used ANSI colors](https://github.com/sickill/rainbow#ansi-colors), so black, red, green, yellow, blue, magenta, cyan, and white. Note that colorize will still be required by Spinach, but since we only use Spinach in the test/dev environments, this isn't a problem. To ensure 100% that tasks run without requiring colorize, you may wish to try removing all spinach-related gems, running `bundle install`, and then `gem uninstall colorize` before running them. I tested all tasks that could be run in dev with Spinach enabled, and then a handful after removing Spinach and uninstalling colorize, and saw no failures or errors in either case. ## Why was this MR needed? Colorize is a GPLv2 gem, which means that we cannot use it without ourselves being GPL'd, which we are not. This is the last gem we use that was breaking the terms of the GPL, so I took it upon myself to remove it. Some argue that libraries can be used without GPL'ing the product itself, but the [GNU Project](http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL), as well as [the Open Source Initiative](https://opensource.org/faq#linking-proprietary-code) disagrees. Out of an abundance of caution, having researched various software licenses extensively, and in the interest of covering ourselves legally, I'm going to go with that interpretation of the license. An attempt at relicensing Colorize was made, but didn’t succeed as the library owner hasn't responded more than four weeks after attempting contact. ## What are the relevant issue numbers? !3775, gitlab-com/operations#164 cc: @sytses, @rspeicher, @rabbitfang, @rymai See merge request !4425
parents e696795a 4cd111e7
...@@ -35,6 +35,7 @@ v 8.9.0 (unreleased) ...@@ -35,6 +35,7 @@ v 8.9.0 (unreleased)
- Reduce number of queries needed to render issue labels in the sidebar - Reduce number of queries needed to render issue labels in the sidebar
- Improve error handling importing projects - Improve error handling importing projects
- Put project Files and Commits tabs under Code tab - Put project Files and Commits tabs under Code tab
- Replace Colorize with Rainbow for coloring console output in Rake tasks.
v 8.8.4 v 8.8.4
- Fix todos page throwing errors when you have a project pending deletion - Fix todos page throwing errors when you have a project pending deletion
......
...@@ -143,7 +143,7 @@ gem 'redis-namespace' ...@@ -143,7 +143,7 @@ gem 'redis-namespace'
gem "httparty", '~> 0.13.3' gem "httparty", '~> 0.13.3'
# Colored output to console # Colored output to console
gem "colorize", '~> 0.7.0' gem "rainbow", '~> 2.1.0'
# GitLab settings # GitLab settings
gem 'settingslogic', '~> 2.0.9' gem 'settingslogic', '~> 2.0.9'
......
...@@ -823,7 +823,6 @@ DEPENDENCIES ...@@ -823,7 +823,6 @@ DEPENDENCIES
carrierwave (~> 0.10.0) carrierwave (~> 0.10.0)
charlock_holmes (~> 0.7.3) charlock_holmes (~> 0.7.3)
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
colorize (~> 0.7.0)
connection_pool (~> 2.0) connection_pool (~> 2.0)
coveralls (~> 0.8.2) coveralls (~> 0.8.2)
creole (~> 0.5.0) creole (~> 0.5.0)
...@@ -914,6 +913,7 @@ DEPENDENCIES ...@@ -914,6 +913,7 @@ DEPENDENCIES
rack-oauth2 (~> 1.2.1) rack-oauth2 (~> 1.2.1)
rails (= 4.2.6) rails (= 4.2.6)
rails-deprecated_sanitizer (~> 1.0.3) rails-deprecated_sanitizer (~> 1.0.3)
rainbow (~> 2.1.0)
raphael-rails (~> 2.1.2) raphael-rails (~> 2.1.2)
rblineprof rblineprof
rdoc (~> 3.6) rdoc (~> 3.6)
......
...@@ -86,9 +86,9 @@ module Backup ...@@ -86,9 +86,9 @@ module Backup
def report_success(success) def report_success(success)
if success if success
$progress.puts '[DONE]'.green $progress.puts '[DONE]'.color(:green)
else else
$progress.puts '[FAILED]'.red $progress.puts '[FAILED]'.color(:red)
end end
end end
end end
......
...@@ -27,9 +27,9 @@ module Backup ...@@ -27,9 +27,9 @@ module Backup
# 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".green $progress.puts "done".color(:green)
else else
puts "creating archive #{tar_file} failed".red puts "creating archive #{tar_file} failed".color(:red)
abort 'Backup failed' abort 'Backup failed'
end end
...@@ -43,7 +43,7 @@ module Backup ...@@ -43,7 +43,7 @@ module Backup
connection_settings = Gitlab.config.backup.upload.connection connection_settings = Gitlab.config.backup.upload.connection
if connection_settings.blank? if connection_settings.blank?
$progress.puts "skipped".yellow $progress.puts "skipped".color(:yellow)
return return
end end
...@@ -53,9 +53,9 @@ module Backup ...@@ -53,9 +53,9 @@ module Backup
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".green $progress.puts "done".color(:green)
else else
puts "uploading backup to #{remote_directory} failed".red puts "uploading backup to #{remote_directory} failed".color(:red)
abort 'Backup failed' abort 'Backup failed'
end end
end end
...@@ -67,9 +67,9 @@ module Backup ...@@ -67,9 +67,9 @@ module Backup
next unless File.exist?(File.join(Gitlab.config.backup.path, dir)) next unless File.exist?(File.join(Gitlab.config.backup.path, dir))
if FileUtils.rm_rf(File.join(Gitlab.config.backup.path, dir)) if FileUtils.rm_rf(File.join(Gitlab.config.backup.path, dir))
$progress.puts "done".green $progress.puts "done".color(:green)
else else
puts "deleting tmp directory '#{dir}' failed".red puts "deleting tmp directory '#{dir}' failed".color(:red)
abort 'Backup failed' abort 'Backup failed'
end end
end end
...@@ -95,9 +95,9 @@ module Backup ...@@ -95,9 +95,9 @@ module Backup
end end
end end
$progress.puts "done. (#{removed} removed)".green $progress.puts "done. (#{removed} removed)".color(:green)
else else
$progress.puts "skipping".yellow $progress.puts "skipping".color(:yellow)
end end
end end
...@@ -124,20 +124,20 @@ module Backup ...@@ -124,20 +124,20 @@ module Backup
$progress.print "Unpacking backup ... " $progress.print "Unpacking backup ... "
unless Kernel.system(*%W(tar -xf #{tar_file})) unless Kernel.system(*%W(tar -xf #{tar_file}))
puts "unpacking backup failed".red puts "unpacking backup failed".color(:red)
exit 1 exit 1
else else
$progress.puts "done".green $progress.puts "done".color(:green)
end end
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
# restoring mismatching backups can lead to unexpected problems # restoring mismatching backups can lead to unexpected problems
if settings[:gitlab_version] != Gitlab::VERSION if settings[:gitlab_version] != Gitlab::VERSION
puts "GitLab version mismatch:".red puts "GitLab version mismatch:".color(:red)
puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".color(:red)
puts " Please switch to the following version and try again:".red puts " Please switch to the following version and try again:".color(:red)
puts " version: #{settings[:gitlab_version]}".red puts " version: #{settings[:gitlab_version]}".color(:red)
puts puts
puts "Hint: git checkout v#{settings[:gitlab_version]}" puts "Hint: git checkout v#{settings[:gitlab_version]}"
exit 1 exit 1
......
...@@ -14,14 +14,14 @@ module Backup ...@@ -14,14 +14,14 @@ module Backup
FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace
if project.empty_repo? if project.empty_repo?
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
cmd = %W(tar -cf #{path_to_bundle(project)} -C #{path_to_repo(project)} .) cmd = %W(tar -cf #{path_to_bundle(project)} -C #{path_to_repo(project)} .)
output, status = Gitlab::Popen.popen(cmd) output, status = Gitlab::Popen.popen(cmd)
if status.zero? if status.zero?
$progress.puts "[DONE]".green $progress.puts "[DONE]".color(:green)
else else
puts "[FAILED]".red puts "[FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}" puts "failed: #{cmd.join(' ')}"
puts output puts output
abort 'Backup failed' abort 'Backup failed'
...@@ -33,14 +33,14 @@ module Backup ...@@ -33,14 +33,14 @@ module Backup
if File.exists?(path_to_repo(wiki)) if File.exists?(path_to_repo(wiki))
$progress.print " * #{wiki.path_with_namespace} ... " $progress.print " * #{wiki.path_with_namespace} ... "
if wiki.repository.empty? if wiki.repository.empty?
$progress.puts " [SKIPPED]".cyan $progress.puts " [SKIPPED]".color(:cyan)
else else
cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all) cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all)
output, status = Gitlab::Popen.popen(cmd) output, status = Gitlab::Popen.popen(cmd)
if status.zero? if status.zero?
$progress.puts " [DONE]".green $progress.puts " [DONE]".color(:green)
else else
puts " [FAILED]".red puts " [FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}" puts "failed: #{cmd.join(' ')}"
abort 'Backup failed' abort 'Backup failed'
end end
...@@ -71,9 +71,9 @@ module Backup ...@@ -71,9 +71,9 @@ module Backup
end end
if system(*cmd, silent) if system(*cmd, silent)
$progress.puts "[DONE]".green $progress.puts "[DONE]".color(:green)
else else
puts "[FAILED]".red puts "[FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}" puts "failed: #{cmd.join(' ')}"
abort 'Restore failed' abort 'Restore failed'
end end
...@@ -90,21 +90,21 @@ module Backup ...@@ -90,21 +90,21 @@ module Backup
cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)}) cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)})
if system(*cmd, silent) if system(*cmd, silent)
$progress.puts " [DONE]".green $progress.puts " [DONE]".color(:green)
else else
puts " [FAILED]".red puts " [FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}" puts "failed: #{cmd.join(' ')}"
abort 'Restore failed' abort 'Restore failed'
end end
end end
end end
$progress.print 'Put GitLab hooks in repositories dirs'.yellow $progress.print 'Put GitLab hooks in repositories dirs'.color(:yellow)
cmd = "#{Gitlab.config.gitlab_shell.path}/bin/create-hooks" cmd = "#{Gitlab.config.gitlab_shell.path}/bin/create-hooks"
if system(cmd) if system(cmd)
$progress.puts " [DONE]".green $progress.puts " [DONE]".color(:green)
else else
puts " [FAILED]".red puts " [FAILED]".color(:red)
puts "failed: #{cmd}" puts "failed: #{cmd}"
end end
......
...@@ -5,7 +5,7 @@ module Gitlab ...@@ -5,7 +5,7 @@ module Gitlab
SeedFu.quiet = true SeedFu.quiet = true
yield yield
SeedFu.quiet = false SeedFu.quiet = false
puts "\nOK".green puts "\nOK".color(:green)
end end
def self.by_user(user) def self.by_user(user)
......
...@@ -40,14 +40,14 @@ namespace :gitlab do ...@@ -40,14 +40,14 @@ namespace :gitlab do
removed. removed.
MSG MSG
ask_to_continue ask_to_continue
puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.yellow puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.color(:yellow)
sleep(5) sleep(5)
end end
# Drop all tables Load the schema to ensure we don't have any newer tables # Drop all tables Load the schema to ensure we don't have any newer tables
# hanging out from a failed upgrade # hanging out from a failed upgrade
$progress.puts 'Cleaning the database ... '.blue $progress.puts 'Cleaning the database ... '.color(:blue)
Rake::Task['gitlab:db:drop_tables'].invoke Rake::Task['gitlab:db:drop_tables'].invoke
$progress.puts 'done'.green $progress.puts 'done'.color(:green)
Rake::Task['gitlab:backup:db:restore'].invoke Rake::Task['gitlab:backup:db:restore'].invoke
end end
Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories') Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories')
...@@ -63,141 +63,141 @@ namespace :gitlab do ...@@ -63,141 +63,141 @@ namespace :gitlab do
namespace :repo do namespace :repo do
task create: :environment do task create: :environment do
$progress.puts "Dumping repositories ...".blue $progress.puts "Dumping repositories ...".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("repositories") if ENV["SKIP"] && ENV["SKIP"].include?("repositories")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Repository.new.dump Backup::Repository.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring repositories ...".blue $progress.puts "Restoring repositories ...".color(:blue)
Backup::Repository.new.restore Backup::Repository.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :db do namespace :db do
task create: :environment do task create: :environment do
$progress.puts "Dumping database ... ".blue $progress.puts "Dumping database ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("db") if ENV["SKIP"] && ENV["SKIP"].include?("db")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Database.new.dump Backup::Database.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring database ... ".blue $progress.puts "Restoring database ... ".color(:blue)
Backup::Database.new.restore Backup::Database.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :builds do namespace :builds do
task create: :environment do task create: :environment do
$progress.puts "Dumping builds ... ".blue $progress.puts "Dumping builds ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("builds") if ENV["SKIP"] && ENV["SKIP"].include?("builds")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Builds.new.dump Backup::Builds.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring builds ... ".blue $progress.puts "Restoring builds ... ".color(:blue)
Backup::Builds.new.restore Backup::Builds.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :uploads do namespace :uploads do
task create: :environment do task create: :environment do
$progress.puts "Dumping uploads ... ".blue $progress.puts "Dumping uploads ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("uploads") if ENV["SKIP"] && ENV["SKIP"].include?("uploads")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Uploads.new.dump Backup::Uploads.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring uploads ... ".blue $progress.puts "Restoring uploads ... ".color(:blue)
Backup::Uploads.new.restore Backup::Uploads.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :artifacts do namespace :artifacts do
task create: :environment do task create: :environment do
$progress.puts "Dumping artifacts ... ".blue $progress.puts "Dumping artifacts ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("artifacts") if ENV["SKIP"] && ENV["SKIP"].include?("artifacts")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Artifacts.new.dump Backup::Artifacts.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring artifacts ... ".blue $progress.puts "Restoring artifacts ... ".color(:blue)
Backup::Artifacts.new.restore Backup::Artifacts.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :lfs do namespace :lfs do
task create: :environment do task create: :environment do
$progress.puts "Dumping lfs objects ... ".blue $progress.puts "Dumping lfs objects ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("lfs") if ENV["SKIP"] && ENV["SKIP"].include?("lfs")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Lfs.new.dump Backup::Lfs.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring lfs objects ... ".blue $progress.puts "Restoring lfs objects ... ".color(:blue)
Backup::Lfs.new.restore Backup::Lfs.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
end end
end end
namespace :registry do namespace :registry do
task create: :environment do task create: :environment do
$progress.puts "Dumping container registry images ... ".blue $progress.puts "Dumping container registry images ... ".color(:blue)
if Gitlab.config.registry.enabled if Gitlab.config.registry.enabled
if ENV["SKIP"] && ENV["SKIP"].include?("registry") if ENV["SKIP"] && ENV["SKIP"].include?("registry")
$progress.puts "[SKIPPED]".cyan $progress.puts "[SKIPPED]".color(:cyan)
else else
Backup::Registry.new.dump Backup::Registry.new.dump
$progress.puts "done".green $progress.puts "done".color(:green)
end end
else else
$progress.puts "[DISABLED]".cyan $progress.puts "[DISABLED]".color(:cyan)
end end
end end
task restore: :environment do task restore: :environment do
$progress.puts "Restoring container registry images ... ".blue $progress.puts "Restoring container registry images ... ".color(:blue)
if Gitlab.config.registry.enabled if Gitlab.config.registry.enabled
Backup::Registry.new.restore Backup::Registry.new.restore
$progress.puts "done".green $progress.puts "done".color(:green)
else else
$progress.puts "[DISABLED]".cyan $progress.puts "[DISABLED]".color(:cyan)
end end
end end
end end
......
...@@ -10,7 +10,7 @@ namespace :gitlab do ...@@ -10,7 +10,7 @@ namespace :gitlab do
git_base_path = Gitlab.config.gitlab_shell.repos_path git_base_path = Gitlab.config.gitlab_shell.repos_path
all_dirs = Dir.glob(git_base_path + '/*') all_dirs = Dir.glob(git_base_path + '/*')
puts git_base_path.yellow puts git_base_path.color(:yellow)
puts "Looking for directories to remove... " puts "Looking for directories to remove... "
all_dirs.reject! do |dir| all_dirs.reject! do |dir|
...@@ -29,17 +29,17 @@ namespace :gitlab do ...@@ -29,17 +29,17 @@ namespace :gitlab do
if remove_flag if remove_flag
if FileUtils.rm_rf dir_path if FileUtils.rm_rf dir_path
puts "Removed...#{dir_path}".red puts "Removed...#{dir_path}".color(:red)
else else
puts "Cannot remove #{dir_path}".red puts "Cannot remove #{dir_path}".color(:red)
end end
else else
puts "Can be removed: #{dir_path}".red puts "Can be removed: #{dir_path}".color(:red)
end end
end end
unless remove_flag unless remove_flag
puts "To cleanup this directories run this command with REMOVE=true".yellow puts "To cleanup this directories run this command with REMOVE=true".color(:yellow)
end end
end end
...@@ -75,19 +75,19 @@ namespace :gitlab do ...@@ -75,19 +75,19 @@ namespace :gitlab do
next unless user.ldap_user? next unless user.ldap_user?
print "#{user.name} (#{user.ldap_identity.extern_uid}) ..." print "#{user.name} (#{user.ldap_identity.extern_uid}) ..."
if Gitlab::LDAP::Access.allowed?(user) if Gitlab::LDAP::Access.allowed?(user)
puts " [OK]".green puts " [OK]".color(:green)
else else
if block_flag if block_flag
user.block! unless user.blocked? user.block! unless user.blocked?
puts " [BLOCKED]".red puts " [BLOCKED]".color(:red)
else else
puts " [NOT IN LDAP]".yellow puts " [NOT IN LDAP]".color(:yellow)
end end
end end
end end
unless block_flag unless block_flag
puts "To block these users run this command with BLOCK=true".yellow puts "To block these users run this command with BLOCK=true".color(:yellow)
end end
end end
end end
......
...@@ -3,22 +3,22 @@ namespace :gitlab do ...@@ -3,22 +3,22 @@ namespace :gitlab do
desc 'GitLab | Manually insert schema migration version' desc 'GitLab | Manually insert schema migration version'
task :mark_migration_complete, [:version] => :environment do |_, args| task :mark_migration_complete, [:version] => :environment do |_, args|
unless args[:version] unless args[:version]
puts "Must specify a migration version as an argument".red puts "Must specify a migration version as an argument".color(:red)
exit 1 exit 1
end end
version = args[:version].to_i version = args[:version].to_i
if version == 0 if version == 0
puts "Version '#{args[:version]}' must be a non-zero integer".red puts "Version '#{args[:version]}' must be a non-zero integer".color(:red)
exit 1 exit 1
end end
sql = "INSERT INTO schema_migrations (version) VALUES (#{version})" sql = "INSERT INTO schema_migrations (version) VALUES (#{version})"
begin begin
ActiveRecord::Base.connection.execute(sql) ActiveRecord::Base.connection.execute(sql)
puts "Successfully marked '#{version}' as complete".green puts "Successfully marked '#{version}' as complete".color(:green)
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
puts "Migration version '#{version}' is already marked complete".yellow puts "Migration version '#{version}' is already marked complete".color(:yellow)
end end
end end
......
...@@ -5,7 +5,7 @@ namespace :gitlab do ...@@ -5,7 +5,7 @@ namespace :gitlab do
task repack: :environment do task repack: :environment do
failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo") failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo")
if failures.empty? if failures.empty?
puts "Done".green puts "Done".color(:green)
else else
output_failures(failures) output_failures(failures)
end end
...@@ -15,7 +15,7 @@ namespace :gitlab do ...@@ -15,7 +15,7 @@ namespace :gitlab do
task gc: :environment do task gc: :environment do
failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting") failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting")
if failures.empty? if failures.empty?
puts "Done".green puts "Done".color(:green)
else else
output_failures(failures) output_failures(failures)
end end
...@@ -25,7 +25,7 @@ namespace :gitlab do ...@@ -25,7 +25,7 @@ namespace :gitlab do
task prune: :environment do task prune: :environment do
failures = perform_git_cmd(%W(git prune), "Git Prune") failures = perform_git_cmd(%W(git prune), "Git Prune")
if failures.empty? if failures.empty?
puts "Done".green puts "Done".color(:green)
else else
output_failures(failures) output_failures(failures)
end end
...@@ -47,7 +47,7 @@ namespace :gitlab do ...@@ -47,7 +47,7 @@ namespace :gitlab do
end end
def output_failures(failures) def output_failures(failures)
puts "The following repositories reported errors:".red puts "The following repositories reported errors:".color(:red)
failures.each { |f| puts "- #{f}" } failures.each { |f| puts "- #{f}" }
end end
......
...@@ -23,7 +23,7 @@ namespace :gitlab do ...@@ -23,7 +23,7 @@ namespace :gitlab do
group_name, name = File.split(path) group_name, name = File.split(path)
group_name = nil if group_name == '.' group_name = nil if group_name == '.'
puts "Processing #{repo_path}".yellow puts "Processing #{repo_path}".color(:yellow)
if path.end_with?('.wiki') if path.end_with?('.wiki')
puts " * Skipping wiki repo" puts " * Skipping wiki repo"
...@@ -51,9 +51,9 @@ namespace :gitlab do ...@@ -51,9 +51,9 @@ namespace :gitlab do
group.path = group_name group.path = group_name
group.owner = user group.owner = user
if group.save if group.save
puts " * Created Group #{group.name} (#{group.id})".green puts " * Created Group #{group.name} (#{group.id})".color(:green)
else else
puts " * Failed trying to create group #{group.name}".red puts " * Failed trying to create group #{group.name}".color(:red)
end end
end end
# set project group # set project group
...@@ -63,17 +63,17 @@ namespace :gitlab do ...@@ -63,17 +63,17 @@ namespace :gitlab do
project = Projects::CreateService.new(user, project_params).execute project = Projects::CreateService.new(user, project_params).execute
if project.persisted? if project.persisted?
puts " * Created #{project.name} (#{repo_path})".green puts " * Created #{project.name} (#{repo_path})".color(:green)
project.update_repository_size project.update_repository_size
project.update_commit_count project.update_commit_count
else else
puts " * Failed trying to create #{project.name} (#{repo_path})".red puts " * Failed trying to create #{project.name} (#{repo_path})".color(:red)
puts " Errors: #{project.errors.messages}".red puts " Errors: #{project.errors.messages}".color(:red)
end end
end end
end end
puts "Done!".green puts "Done!".color(:green)
end end
end end
end end
...@@ -15,15 +15,15 @@ namespace :gitlab do ...@@ -15,15 +15,15 @@ namespace :gitlab do
rake_version = run_and_match(%W(rake --version), /[\d\.]+/).try(:to_s) rake_version = run_and_match(%W(rake --version), /[\d\.]+/).try(:to_s)
puts "" puts ""
puts "System information".yellow puts "System information".color(:yellow)
puts "System:\t\t#{os_name || "unknown".red}" puts "System:\t\t#{os_name || "unknown".color(:red)}"
puts "Current User:\t#{run(%W(whoami))}" puts "Current User:\t#{run(%W(whoami))}"
puts "Using RVM:\t#{rvm_version.present? ? "yes".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".red}" puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
puts "Gem Version:\t#{gem_version || "unknown".red}" puts "Gem Version:\t#{gem_version || "unknown".color(:red)}"
puts "Bundler Version:#{bunder_version || "unknown".red}" puts "Bundler Version:#{bunder_version || "unknown".color(:red)}"
puts "Rake Version:\t#{rake_version || "unknown".red}" puts "Rake Version:\t#{rake_version || "unknown".color(:red)}"
puts "Sidekiq Version:#{Sidekiq::VERSION}" puts "Sidekiq Version:#{Sidekiq::VERSION}"
...@@ -39,7 +39,7 @@ namespace :gitlab do ...@@ -39,7 +39,7 @@ namespace :gitlab do
omniauth_providers.map! { |provider| provider['name'] } omniauth_providers.map! { |provider| provider['name'] }
puts "" puts ""
puts "GitLab information".yellow puts "GitLab information".color(:yellow)
puts "Version:\t#{Gitlab::VERSION}" puts "Version:\t#{Gitlab::VERSION}"
puts "Revision:\t#{Gitlab::REVISION}" puts "Revision:\t#{Gitlab::REVISION}"
puts "Directory:\t#{Rails.root}" puts "Directory:\t#{Rails.root}"
...@@ -47,9 +47,9 @@ namespace :gitlab do ...@@ -47,9 +47,9 @@ namespace :gitlab do
puts "URL:\t\t#{Gitlab.config.gitlab.url}" puts "URL:\t\t#{Gitlab.config.gitlab.url}"
puts "HTTP Clone URL:\t#{http_clone_url}" puts "HTTP Clone URL:\t#{http_clone_url}"
puts "SSH Clone URL:\t#{ssh_clone_url}" puts "SSH Clone URL:\t#{ssh_clone_url}"
puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".green : "no"}" puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".color(:green) : "no"}"
puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".green : "no"}" puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".color(:green) : "no"}"
puts "Omniauth Providers: #{omniauth_providers.map(&:magenta).join(', ')}" if Gitlab.config.omniauth.enabled puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab.config.omniauth.enabled
...@@ -60,8 +60,8 @@ namespace :gitlab do ...@@ -60,8 +60,8 @@ namespace :gitlab do
end end
puts "" puts ""
puts "GitLab Shell".yellow puts "GitLab Shell".color(:yellow)
puts "Version:\t#{gitlab_shell_version || "unknown".red}" puts "Version:\t#{gitlab_shell_version || "unknown".color(:red)}"
puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}" puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}"
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}"
......
...@@ -118,12 +118,12 @@ namespace :gitlab do ...@@ -118,12 +118,12 @@ namespace :gitlab do
puts "" puts ""
unless $?.success? unless $?.success?
puts "Failed to add keys...".red puts "Failed to add keys...".color(:red)
exit 1 exit 1
end end
rescue Gitlab::TaskAbortedByUserError rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".red puts "Quitting...".color(:red)
exit 1 exit 1
end end
......
...@@ -2,7 +2,7 @@ module Gitlab ...@@ -2,7 +2,7 @@ module Gitlab
class TaskAbortedByUserError < StandardError; end class TaskAbortedByUserError < StandardError; end
end end
String.disable_colorization = true unless STDOUT.isatty require 'rainbow/ext/string'
# Prevent StateMachine warnings from outputting during a cron task # Prevent StateMachine warnings from outputting during a cron task
StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON'] StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
...@@ -14,7 +14,7 @@ namespace :gitlab do ...@@ -14,7 +14,7 @@ namespace :gitlab do
# Returns "yes" the user chose to continue # Returns "yes" the user chose to continue
# Raises Gitlab::TaskAbortedByUserError if the user chose *not* to continue # Raises Gitlab::TaskAbortedByUserError if the user chose *not* to continue
def ask_to_continue def ask_to_continue
answer = prompt("Do you want to continue (yes/no)? ".blue, %w{yes no}) answer = prompt("Do you want to continue (yes/no)? ".color(:blue), %w{yes no})
raise Gitlab::TaskAbortedByUserError unless answer == "yes" raise Gitlab::TaskAbortedByUserError unless answer == "yes"
end end
...@@ -98,10 +98,10 @@ namespace :gitlab do ...@@ -98,10 +98,10 @@ namespace :gitlab do
gitlab_user = Gitlab.config.gitlab.user gitlab_user = Gitlab.config.gitlab.user
current_user = run(%W(whoami)).chomp current_user = run(%W(whoami)).chomp
unless current_user == gitlab_user unless current_user == gitlab_user
puts " Warning ".colorize(:black).on_yellow puts " Warning ".color(:black).background(:yellow)
puts " You are running as user #{current_user.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."
puts " Things may work\/fail for the wrong reasons." puts " Things may work\/fail for the wrong reasons."
puts " For correct results you should run this as user #{gitlab_user.magenta}." puts " For correct results you should run this as user #{gitlab_user.color(:magenta)}."
puts "" puts ""
end end
@warned_user_not_gitlab = true @warned_user_not_gitlab = true
......
...@@ -6,17 +6,17 @@ namespace :gitlab do ...@@ -6,17 +6,17 @@ namespace :gitlab do
count = scope.count count = scope.count
if count > 0 if count > 0
puts "This will disable 2FA for #{count.to_s.red} users..." puts "This will disable 2FA for #{count.to_s.color(:red)} users..."
begin begin
ask_to_continue ask_to_continue
scope.find_each(&:disable_two_factor!) scope.find_each(&:disable_two_factor!)
puts "Successfully disabled 2FA for #{count} users.".green puts "Successfully disabled 2FA for #{count} users.".color(:green)
rescue Gitlab::TaskAbortedByUserError rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".red puts "Quitting...".color(:red)
end end
else else
puts "There are currently no users with 2FA enabled.".yellow puts "There are currently no users with 2FA enabled.".color(:yellow)
end end
end end
end end
......
...@@ -6,15 +6,15 @@ namespace :gitlab do ...@@ -6,15 +6,15 @@ namespace :gitlab do
ask_to_continue unless ENV['force'] == 'yes' ask_to_continue unless ENV['force'] == 'yes'
projects.find_each(batch_size: 100) do |project| projects.find_each(batch_size: 100) do |project|
print "#{project.name_with_namespace.yellow} ... " print "#{project.name_with_namespace.color(:yellow)} ... "
unless project.repo_exists? unless project.repo_exists?
puts "skipping, because the repo is empty".magenta puts "skipping, because the repo is empty".color(:magenta)
next next
end end
project.update_commit_count project.update_commit_count
puts project.commit_count.to_s.green puts project.commit_count.to_s.color(:green)
end end
end end
end end
...@@ -2,14 +2,14 @@ namespace :gitlab do ...@@ -2,14 +2,14 @@ namespace :gitlab do
desc "GitLab | Update gitignore" desc "GitLab | Update gitignore"
task :update_gitignore do task :update_gitignore do
unless clone_gitignores unless clone_gitignores
puts "Cloning the gitignores failed".red puts "Cloning the gitignores failed".color(:red)
return return
end end
remove_unneeded_files(gitignore_directory) remove_unneeded_files(gitignore_directory)
remove_unneeded_files(global_directory) remove_unneeded_files(global_directory)
puts "Done".green puts "Done".color(:green)
end end
def clone_gitignores def clone_gitignores
......
...@@ -12,9 +12,9 @@ namespace :gitlab do ...@@ -12,9 +12,9 @@ namespace :gitlab do
print "- #{project.name} ... " print "- #{project.name} ... "
web_hook = project.hooks.new(url: web_hook_url) web_hook = project.hooks.new(url: web_hook_url)
if web_hook.save if web_hook.save
puts "added".green puts "added".color(:green)
else else
print "failed".red print "failed".color(:red)
puts " [#{web_hook.errors.full_messages.to_sentence}]" puts " [#{web_hook.errors.full_messages.to_sentence}]"
end end
end end
...@@ -57,7 +57,7 @@ namespace :gitlab do ...@@ -57,7 +57,7 @@ namespace :gitlab do
if namespace if namespace
Project.in_namespace(namespace.id) Project.in_namespace(namespace.id)
else else
puts "Namespace not found: #{namespace_path}".red puts "Namespace not found: #{namespace_path}".color(:red)
exit 2 exit 2
end end
end end
......
desc "GitLab | Build internal ids for issues and merge requests" desc "GitLab | Build internal ids for issues and merge requests"
task migrate_iids: :environment do task migrate_iids: :environment do
puts 'Issues'.yellow puts 'Issues'.color(:yellow)
Issue.where(iid: nil).find_each(batch_size: 100) do |issue| Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
begin begin
issue.set_iid issue.set_iid
...@@ -15,7 +15,7 @@ task migrate_iids: :environment do ...@@ -15,7 +15,7 @@ task migrate_iids: :environment do
end end
puts 'done' puts 'done'
puts 'Merge Requests'.yellow puts 'Merge Requests'.color(:yellow)
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr| MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
begin begin
mr.set_iid mr.set_iid
...@@ -30,7 +30,7 @@ task migrate_iids: :environment do ...@@ -30,7 +30,7 @@ task migrate_iids: :environment do
end end
puts 'done' puts 'done'
puts 'Milestones'.yellow puts 'Milestones'.color(:yellow)
Milestone.where(iid: nil).find_each(batch_size: 100) do |m| Milestone.where(iid: nil).find_each(batch_size: 100) do |m|
begin begin
m.set_iid m.set_iid
......
...@@ -52,7 +52,7 @@ def run_spinach_tests(tags) ...@@ -52,7 +52,7 @@ def run_spinach_tests(tags)
tests = File.foreach('tmp/spinach-rerun.txt').map(&:chomp) tests = File.foreach('tmp/spinach-rerun.txt').map(&:chomp)
puts '' puts ''
puts "Spinach tests for #{tags}: Retrying tests... #{tests}".red puts "Spinach tests for #{tags}: Retrying tests... #{tests}".color(:red)
puts '' puts ''
sleep(3) sleep(3)
success = run_spinach_command(tests) success = run_spinach_command(tests)
......
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