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)
- Reduce number of queries needed to render issue labels in the sidebar
- Improve error handling importing projects
- Put project Files and Commits tabs under Code tab
- Replace Colorize with Rainbow for coloring console output in Rake tasks.
v 8.8.4
- Fix todos page throwing errors when you have a project pending deletion
......
......@@ -143,7 +143,7 @@ gem 'redis-namespace'
gem "httparty", '~> 0.13.3'
# Colored output to console
gem "colorize", '~> 0.7.0'
gem "rainbow", '~> 2.1.0'
# GitLab settings
gem 'settingslogic', '~> 2.0.9'
......
......@@ -823,7 +823,6 @@ DEPENDENCIES
carrierwave (~> 0.10.0)
charlock_holmes (~> 0.7.3)
coffee-rails (~> 4.1.0)
colorize (~> 0.7.0)
connection_pool (~> 2.0)
coveralls (~> 0.8.2)
creole (~> 0.5.0)
......@@ -914,6 +913,7 @@ DEPENDENCIES
rack-oauth2 (~> 1.2.1)
rails (= 4.2.6)
rails-deprecated_sanitizer (~> 1.0.3)
rainbow (~> 2.1.0)
raphael-rails (~> 2.1.2)
rblineprof
rdoc (~> 3.6)
......
......@@ -86,9 +86,9 @@ module Backup
def report_success(success)
if success
$progress.puts '[DONE]'.green
$progress.puts '[DONE]'.color(:green)
else
$progress.puts '[FAILED]'.red
$progress.puts '[FAILED]'.color(:red)
end
end
end
......
......@@ -27,9 +27,9 @@ module Backup
# Set file permissions on open to prevent chmod races.
tar_system_options = {out: [tar_file, 'w', Gitlab.config.backup.archive_permissions]}
if Kernel.system('tar', '-cf', '-', *backup_contents, tar_system_options)
$progress.puts "done".green
$progress.puts "done".color(:green)
else
puts "creating archive #{tar_file} failed".red
puts "creating archive #{tar_file} failed".color(:red)
abort 'Backup failed'
end
......@@ -43,7 +43,7 @@ module Backup
connection_settings = Gitlab.config.backup.upload.connection
if connection_settings.blank?
$progress.puts "skipped".yellow
$progress.puts "skipped".color(:yellow)
return
end
......@@ -53,9 +53,9 @@ module Backup
if directory.files.create(key: tar_file, body: File.open(tar_file), public: false,
multipart_chunk_size: Gitlab.config.backup.upload.multipart_chunk_size,
encryption: Gitlab.config.backup.upload.encryption)
$progress.puts "done".green
$progress.puts "done".color(:green)
else
puts "uploading backup to #{remote_directory} failed".red
puts "uploading backup to #{remote_directory} failed".color(:red)
abort 'Backup failed'
end
end
......@@ -67,9 +67,9 @@ module Backup
next unless File.exist?(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
puts "deleting tmp directory '#{dir}' failed".red
puts "deleting tmp directory '#{dir}' failed".color(:red)
abort 'Backup failed'
end
end
......@@ -95,9 +95,9 @@ module Backup
end
end
$progress.puts "done. (#{removed} removed)".green
$progress.puts "done. (#{removed} removed)".color(:green)
else
$progress.puts "skipping".yellow
$progress.puts "skipping".color(:yellow)
end
end
......@@ -124,20 +124,20 @@ module Backup
$progress.print "Unpacking backup ... "
unless Kernel.system(*%W(tar -xf #{tar_file}))
puts "unpacking backup failed".red
puts "unpacking backup failed".color(:red)
exit 1
else
$progress.puts "done".green
$progress.puts "done".color(:green)
end
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
# restoring mismatching backups can lead to unexpected problems
if settings[:gitlab_version] != Gitlab::VERSION
puts "GitLab version mismatch:".red
puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red
puts " Please switch to the following version and try again:".red
puts " version: #{settings[:gitlab_version]}".red
puts "GitLab version mismatch:".color(: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:".color(:red)
puts " version: #{settings[:gitlab_version]}".color(:red)
puts
puts "Hint: git checkout v#{settings[:gitlab_version]}"
exit 1
......
......@@ -14,14 +14,14 @@ module Backup
FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace
if project.empty_repo?
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
cmd = %W(tar -cf #{path_to_bundle(project)} -C #{path_to_repo(project)} .)
output, status = Gitlab::Popen.popen(cmd)
if status.zero?
$progress.puts "[DONE]".green
$progress.puts "[DONE]".color(:green)
else
puts "[FAILED]".red
puts "[FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}"
puts output
abort 'Backup failed'
......@@ -33,14 +33,14 @@ module Backup
if File.exists?(path_to_repo(wiki))
$progress.print " * #{wiki.path_with_namespace} ... "
if wiki.repository.empty?
$progress.puts " [SKIPPED]".cyan
$progress.puts " [SKIPPED]".color(:cyan)
else
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)
if status.zero?
$progress.puts " [DONE]".green
$progress.puts " [DONE]".color(:green)
else
puts " [FAILED]".red
puts " [FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}"
abort 'Backup failed'
end
......@@ -71,9 +71,9 @@ module Backup
end
if system(*cmd, silent)
$progress.puts "[DONE]".green
$progress.puts "[DONE]".color(:green)
else
puts "[FAILED]".red
puts "[FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}"
abort 'Restore failed'
end
......@@ -90,21 +90,21 @@ module Backup
cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)})
if system(*cmd, silent)
$progress.puts " [DONE]".green
$progress.puts " [DONE]".color(:green)
else
puts " [FAILED]".red
puts " [FAILED]".color(:red)
puts "failed: #{cmd.join(' ')}"
abort 'Restore failed'
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"
if system(cmd)
$progress.puts " [DONE]".green
$progress.puts " [DONE]".color(:green)
else
puts " [FAILED]".red
puts " [FAILED]".color(:red)
puts "failed: #{cmd}"
end
......
......@@ -5,7 +5,7 @@ module Gitlab
SeedFu.quiet = true
yield
SeedFu.quiet = false
puts "\nOK".green
puts "\nOK".color(:green)
end
def self.by_user(user)
......
......@@ -40,14 +40,14 @@ namespace :gitlab do
removed.
MSG
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)
end
# Drop all tables Load the schema to ensure we don't have any newer tables
# 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
$progress.puts 'done'.green
$progress.puts 'done'.color(:green)
Rake::Task['gitlab:backup:db:restore'].invoke
end
Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories')
......@@ -63,141 +63,141 @@ namespace :gitlab do
namespace :repo do
task create: :environment do
$progress.puts "Dumping repositories ...".blue
$progress.puts "Dumping repositories ...".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("repositories")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Repository.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring repositories ...".blue
$progress.puts "Restoring repositories ...".color(:blue)
Backup::Repository.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :db do
task create: :environment do
$progress.puts "Dumping database ... ".blue
$progress.puts "Dumping database ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("db")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Database.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring database ... ".blue
$progress.puts "Restoring database ... ".color(:blue)
Backup::Database.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :builds do
task create: :environment do
$progress.puts "Dumping builds ... ".blue
$progress.puts "Dumping builds ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("builds")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Builds.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring builds ... ".blue
$progress.puts "Restoring builds ... ".color(:blue)
Backup::Builds.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :uploads do
task create: :environment do
$progress.puts "Dumping uploads ... ".blue
$progress.puts "Dumping uploads ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("uploads")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Uploads.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring uploads ... ".blue
$progress.puts "Restoring uploads ... ".color(:blue)
Backup::Uploads.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :artifacts do
task create: :environment do
$progress.puts "Dumping artifacts ... ".blue
$progress.puts "Dumping artifacts ... ".color(:blue)
if ENV["SKIP"] && ENV["SKIP"].include?("artifacts")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Artifacts.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring artifacts ... ".blue
$progress.puts "Restoring artifacts ... ".color(:blue)
Backup::Artifacts.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :lfs 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")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Lfs.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
task restore: :environment do
$progress.puts "Restoring lfs objects ... ".blue
$progress.puts "Restoring lfs objects ... ".color(:blue)
Backup::Lfs.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
end
end
namespace :registry 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 ENV["SKIP"] && ENV["SKIP"].include?("registry")
$progress.puts "[SKIPPED]".cyan
$progress.puts "[SKIPPED]".color(:cyan)
else
Backup::Registry.new.dump
$progress.puts "done".green
$progress.puts "done".color(:green)
end
else
$progress.puts "[DISABLED]".cyan
$progress.puts "[DISABLED]".color(:cyan)
end
end
task restore: :environment do
$progress.puts "Restoring container registry images ... ".blue
$progress.puts "Restoring container registry images ... ".color(:blue)
if Gitlab.config.registry.enabled
Backup::Registry.new.restore
$progress.puts "done".green
$progress.puts "done".color(:green)
else
$progress.puts "[DISABLED]".cyan
$progress.puts "[DISABLED]".color(:cyan)
end
end
end
......
......@@ -10,7 +10,7 @@ namespace :gitlab do
git_base_path = Gitlab.config.gitlab_shell.repos_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... "
all_dirs.reject! do |dir|
......@@ -29,17 +29,17 @@ namespace :gitlab do
if remove_flag
if FileUtils.rm_rf dir_path
puts "Removed...#{dir_path}".red
puts "Removed...#{dir_path}".color(:red)
else
puts "Cannot remove #{dir_path}".red
puts "Cannot remove #{dir_path}".color(:red)
end
else
puts "Can be removed: #{dir_path}".red
puts "Can be removed: #{dir_path}".color(:red)
end
end
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
......@@ -75,19 +75,19 @@ namespace :gitlab do
next unless user.ldap_user?
print "#{user.name} (#{user.ldap_identity.extern_uid}) ..."
if Gitlab::LDAP::Access.allowed?(user)
puts " [OK]".green
puts " [OK]".color(:green)
else
if block_flag
user.block! unless user.blocked?
puts " [BLOCKED]".red
puts " [BLOCKED]".color(:red)
else
puts " [NOT IN LDAP]".yellow
puts " [NOT IN LDAP]".color(:yellow)
end
end
end
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
......
......@@ -3,22 +3,22 @@ namespace :gitlab do
desc 'GitLab | Manually insert schema migration version'
task :mark_migration_complete, [:version] => :environment do |_, args|
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
end
version = args[:version].to_i
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
end
sql = "INSERT INTO schema_migrations (version) VALUES (#{version})"
begin
ActiveRecord::Base.connection.execute(sql)
puts "Successfully marked '#{version}' as complete".green
puts "Successfully marked '#{version}' as complete".color(:green)
rescue ActiveRecord::RecordNotUnique
puts "Migration version '#{version}' is already marked complete".yellow
puts "Migration version '#{version}' is already marked complete".color(:yellow)
end
end
......
......@@ -5,7 +5,7 @@ namespace :gitlab do
task repack: :environment do
failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo")
if failures.empty?
puts "Done".green
puts "Done".color(:green)
else
output_failures(failures)
end
......@@ -15,7 +15,7 @@ namespace :gitlab do
task gc: :environment do
failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting")
if failures.empty?
puts "Done".green
puts "Done".color(:green)
else
output_failures(failures)
end
......@@ -25,7 +25,7 @@ namespace :gitlab do
task prune: :environment do
failures = perform_git_cmd(%W(git prune), "Git Prune")
if failures.empty?
puts "Done".green
puts "Done".color(:green)
else
output_failures(failures)
end
......@@ -47,7 +47,7 @@ namespace :gitlab do
end
def output_failures(failures)
puts "The following repositories reported errors:".red
puts "The following repositories reported errors:".color(:red)
failures.each { |f| puts "- #{f}" }
end
......
......@@ -23,7 +23,7 @@ namespace :gitlab do
group_name, name = File.split(path)
group_name = nil if group_name == '.'
puts "Processing #{repo_path}".yellow
puts "Processing #{repo_path}".color(:yellow)
if path.end_with?('.wiki')
puts " * Skipping wiki repo"
......@@ -51,9 +51,9 @@ namespace :gitlab do
group.path = group_name
group.owner = user
if group.save
puts " * Created Group #{group.name} (#{group.id})".green
puts " * Created Group #{group.name} (#{group.id})".color(:green)
else
puts " * Failed trying to create group #{group.name}".red
puts " * Failed trying to create group #{group.name}".color(:red)
end
end
# set project group
......@@ -63,17 +63,17 @@ namespace :gitlab do
project = Projects::CreateService.new(user, project_params).execute
if project.persisted?
puts " * Created #{project.name} (#{repo_path})".green
puts " * Created #{project.name} (#{repo_path})".color(:green)
project.update_repository_size
project.update_commit_count
else
puts " * Failed trying to create #{project.name} (#{repo_path})".red
puts " Errors: #{project.errors.messages}".red
puts " * Failed trying to create #{project.name} (#{repo_path})".color(:red)
puts " Errors: #{project.errors.messages}".color(:red)
end
end
end
puts "Done!".green
puts "Done!".color(:green)
end
end
end
......@@ -15,15 +15,15 @@ namespace :gitlab do
rake_version = run_and_match(%W(rake --version), /[\d\.]+/).try(:to_s)
puts ""
puts "System information".yellow
puts "System:\t\t#{os_name || "unknown".red}"
puts "System information".color(:yellow)
puts "System:\t\t#{os_name || "unknown".color(:red)}"
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 "Ruby Version:\t#{ruby_version || "unknown".red}"
puts "Gem Version:\t#{gem_version || "unknown".red}"
puts "Bundler Version:#{bunder_version || "unknown".red}"
puts "Rake Version:\t#{rake_version || "unknown".red}"
puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
puts "Gem Version:\t#{gem_version || "unknown".color(:red)}"
puts "Bundler Version:#{bunder_version || "unknown".color(:red)}"
puts "Rake Version:\t#{rake_version || "unknown".color(:red)}"
puts "Sidekiq Version:#{Sidekiq::VERSION}"
......@@ -39,7 +39,7 @@ namespace :gitlab do
omniauth_providers.map! { |provider| provider['name'] }
puts ""
puts "GitLab information".yellow
puts "GitLab information".color(:yellow)
puts "Version:\t#{Gitlab::VERSION}"
puts "Revision:\t#{Gitlab::REVISION}"
puts "Directory:\t#{Rails.root}"
......@@ -47,9 +47,9 @@ namespace :gitlab do
puts "URL:\t\t#{Gitlab.config.gitlab.url}"
puts "HTTP Clone URL:\t#{http_clone_url}"
puts "SSH Clone URL:\t#{ssh_clone_url}"
puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".green : "no"}"
puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".green : "no"}"
puts "Omniauth Providers: #{omniauth_providers.map(&:magenta).join(', ')}" if Gitlab.config.omniauth.enabled
puts "Using LDAP:\t#{Gitlab.config.ldap.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
......@@ -60,8 +60,8 @@ namespace :gitlab do
end
puts ""
puts "GitLab Shell".yellow
puts "Version:\t#{gitlab_shell_version || "unknown".red}"
puts "GitLab Shell".color(:yellow)
puts "Version:\t#{gitlab_shell_version || "unknown".color(:red)}"
puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}"
puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
puts "Git:\t\t#{Gitlab.config.git.bin_path}"
......
......@@ -118,12 +118,12 @@ namespace :gitlab do
puts ""
unless $?.success?
puts "Failed to add keys...".red
puts "Failed to add keys...".color(:red)
exit 1
end
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".red
puts "Quitting...".color(:red)
exit 1
end
......
......@@ -2,7 +2,7 @@ module Gitlab
class TaskAbortedByUserError < StandardError; end
end
String.disable_colorization = true unless STDOUT.isatty
require 'rainbow/ext/string'
# Prevent StateMachine warnings from outputting during a cron task
StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
......@@ -14,7 +14,7 @@ namespace :gitlab do
# Returns "yes" the user chose to continue
# Raises Gitlab::TaskAbortedByUserError if the user chose *not* 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"
end
......@@ -98,10 +98,10 @@ namespace :gitlab do
gitlab_user = Gitlab.config.gitlab.user
current_user = run(%W(whoami)).chomp
unless current_user == gitlab_user
puts " Warning ".colorize(:black).on_yellow
puts " You are running as user #{current_user.magenta}, we hope you know what you are doing."
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 " 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 ""
end
@warned_user_not_gitlab = true
......
......@@ -6,17 +6,17 @@ namespace :gitlab do
count = scope.count
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
ask_to_continue
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
puts "Quitting...".red
puts "Quitting...".color(:red)
end
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
......
......@@ -6,15 +6,15 @@ namespace :gitlab do
ask_to_continue unless ENV['force'] == 'yes'
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?
puts "skipping, because the repo is empty".magenta
puts "skipping, because the repo is empty".color(:magenta)
next
end
project.update_commit_count
puts project.commit_count.to_s.green
puts project.commit_count.to_s.color(:green)
end
end
end
......@@ -2,14 +2,14 @@ namespace :gitlab do
desc "GitLab | Update gitignore"
task :update_gitignore do
unless clone_gitignores
puts "Cloning the gitignores failed".red
puts "Cloning the gitignores failed".color(:red)
return
end
remove_unneeded_files(gitignore_directory)
remove_unneeded_files(global_directory)
puts "Done".green
puts "Done".color(:green)
end
def clone_gitignores
......
......@@ -12,9 +12,9 @@ namespace :gitlab do
print "- #{project.name} ... "
web_hook = project.hooks.new(url: web_hook_url)
if web_hook.save
puts "added".green
puts "added".color(:green)
else
print "failed".red
print "failed".color(:red)
puts " [#{web_hook.errors.full_messages.to_sentence}]"
end
end
......@@ -57,7 +57,7 @@ namespace :gitlab do
if namespace
Project.in_namespace(namespace.id)
else
puts "Namespace not found: #{namespace_path}".red
puts "Namespace not found: #{namespace_path}".color(:red)
exit 2
end
end
......
desc "GitLab | Build internal ids for issues and merge requests"
task migrate_iids: :environment do
puts 'Issues'.yellow
puts 'Issues'.color(:yellow)
Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
begin
issue.set_iid
......@@ -15,7 +15,7 @@ task migrate_iids: :environment do
end
puts 'done'
puts 'Merge Requests'.yellow
puts 'Merge Requests'.color(:yellow)
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
begin
mr.set_iid
......@@ -30,7 +30,7 @@ task migrate_iids: :environment do
end
puts 'done'
puts 'Milestones'.yellow
puts 'Milestones'.color(:yellow)
Milestone.where(iid: nil).find_each(batch_size: 100) do |m|
begin
m.set_iid
......
......@@ -52,7 +52,7 @@ def run_spinach_tests(tags)
tests = File.foreach('tmp/spinach-rerun.txt').map(&:chomp)
puts ''
puts "Spinach tests for #{tags}: Retrying tests... #{tests}".red
puts "Spinach tests for #{tags}: Retrying tests... #{tests}".color(:red)
puts ''
sleep(3)
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