diff options
author | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2016-04-29 17:25:03 +0300 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-05-20 23:58:36 +0300 |
commit | e166a8022a3f239938a1449a0a8ce3485f309766 (patch) | |
tree | af9f612f599b01f5736e7b439f9579d77658f156 /lib/tasks | |
parent | 56eb42007ae8c3c390b35bf336884b3bad3591c5 (diff) |
Backend for a gitignores dropdown
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/update_gitignore.rake | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/update_gitignore.rake b/lib/tasks/gitlab/update_gitignore.rake new file mode 100644 index 00000000000..61cbfd6737d --- /dev/null +++ b/lib/tasks/gitlab/update_gitignore.rake @@ -0,0 +1,26 @@ +namespace :gitlab do + desc "GitLab | Update gitignore" + task :update_gitignore do + dir = File.expand_path('vendor', Rails.root) + FileUtils.cd(dir) + + dir = File.expand_path('gitignore', dir) + clone_gitignores(dir) + remove_unneeded_files(dir) + + puts "Done".green + end + + def clone_gitignores(dir) + FileUtils.rm_rf(dir) if Dir.exist?(dir) + system('git clone --depth=1 --branch=master https://github.com/github/gitignore.git') + end + + def remove_unneeded_files(dir) + [File.expand_path('Global', dir), dir].each do |path| + Dir.entries(path).reject { |e| e =~ /(\.{1,2}|Global|\.gitignore)\z/ }.each do |file| + FileUtils.rm_rf File.expand_path(file, path) + end + end + end +end |