903946c78a
Colorize is a gem licensed under the GPLv2, so we can’t use it in GitLab without relicensing GitLab under the terms of the GPL. Rainbow is licensed under the MIT license and does the exact same thing as Colorize, so Rainbow was added in place of Colorize. The syntax is slightly different for Rainbow vs. Colorize, and was updated in accordance. The gem is still a dependency of Spinach, so it’s included in the development/test environments, but won’t be packaged with the actual product, and therefore doesn’t require we relicense the product. An attempt at relicensing Colorize was made, but didn’t succeed as the library owner never responded. Rainbow library: https://github.com/sickill/rainbow Relevant issue regarding licensing in GitLab's gems: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3775
55 lines
1.3 KiB
Ruby
55 lines
1.3 KiB
Ruby
namespace :gitlab do
|
|
namespace :git do
|
|
|
|
desc "GitLab | Git | Repack"
|
|
task repack: :environment do
|
|
failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo")
|
|
if failures.empty?
|
|
puts "Done".color(:green)
|
|
else
|
|
output_failures(failures)
|
|
end
|
|
end
|
|
|
|
desc "GitLab | Git | Run garbage collection on all repos"
|
|
task gc: :environment do
|
|
failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting")
|
|
if failures.empty?
|
|
puts "Done".color(:green)
|
|
else
|
|
output_failures(failures)
|
|
end
|
|
end
|
|
|
|
desc "GitLab | Git | Prune all repos"
|
|
task prune: :environment do
|
|
failures = perform_git_cmd(%W(git prune), "Git Prune")
|
|
if failures.empty?
|
|
puts "Done".color(:green)
|
|
else
|
|
output_failures(failures)
|
|
end
|
|
end
|
|
|
|
def perform_git_cmd(cmd, message)
|
|
puts "Starting #{message} on all repositories"
|
|
|
|
failures = []
|
|
all_repos do |repo|
|
|
if system(*cmd, chdir: repo)
|
|
puts "Performed #{message} at #{repo}"
|
|
else
|
|
failures << repo
|
|
end
|
|
end
|
|
|
|
failures
|
|
end
|
|
|
|
def output_failures(failures)
|
|
puts "The following repositories reported errors:".color(:red)
|
|
failures.each { |f| puts "- #{f}" }
|
|
end
|
|
|
|
end
|
|
end
|