gitlab-org--gitlab-foss/lib/tasks/gitlab/update_gitignore.rake
Connor Shea 903946c78a
Replace colorize gem with rainbow.
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
2016-06-03 10:37:09 -06:00

46 lines
1.1 KiB
Ruby

namespace :gitlab do
desc "GitLab | Update gitignore"
task :update_gitignore do
unless clone_gitignores
puts "Cloning the gitignores failed".color(:red)
return
end
remove_unneeded_files(gitignore_directory)
remove_unneeded_files(global_directory)
puts "Done".color(:green)
end
def clone_gitignores
FileUtils.rm_rf(gitignore_directory) if Dir.exist?(gitignore_directory)
FileUtils.cd vendor_directory
system('git clone --depth=1 --branch=master https://github.com/github/gitignore.git')
end
# Retain only certain files:
# - The LICENSE, because we have to
# - The sub dir global
# - The gitignores themself
# - Dir.entires returns also the entries '.' and '..'
def remove_unneeded_files(path)
Dir.foreach(path) do |file|
FileUtils.rm_rf(File.join(path, file)) unless file =~ /(\.{1,2}|LICENSE|Global|\.gitignore)\z/
end
end
private
def vendor_directory
Rails.root.join('vendor')
end
def gitignore_directory
File.join(vendor_directory, 'gitignore')
end
def global_directory
File.join(gitignore_directory, 'Global')
end
end