Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2016-05-12 14:27:25 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-05-20 23:58:36 +0300
commit79620c501da19bfda5818b8dca75b6ec9c10e762 (patch)
treedeff7dbc8d3c60410543cc723e21ae438796e78f /lib/tasks
parent1f5fcb638d6b432d76a639ccc35acc94d8ae6ac7 (diff)
Update API and fetching task
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/update_gitignore.rake44
1 files changed, 32 insertions, 12 deletions
diff --git a/lib/tasks/gitlab/update_gitignore.rake b/lib/tasks/gitlab/update_gitignore.rake
index 61cbfd6737d..84aa312002b 100644
--- a/lib/tasks/gitlab/update_gitignore.rake
+++ b/lib/tasks/gitlab/update_gitignore.rake
@@ -1,26 +1,46 @@
namespace :gitlab do
desc "GitLab | Update gitignore"
task :update_gitignore do
- dir = File.expand_path('vendor', Rails.root)
- FileUtils.cd(dir)
+ unless clone_gitignores
+ puts "Cloning the gitignores failed".red
+ return
+ end
- dir = File.expand_path('gitignore', dir)
- clone_gitignores(dir)
- remove_unneeded_files(dir)
+ remove_unneeded_files(gitignore_directory)
+ remove_unneeded_files(global_directory)
puts "Done".green
end
- def clone_gitignores(dir)
- FileUtils.rm_rf(dir) if Dir.exist?(dir)
+ 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
- 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
+ # 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