public
Description: A collection of Sake tasks for use on multiple projects
Homepage: http://www.viget.com/extend/
Clone URL: git://github.com/vigetlabs/sake-tasks.git
sake-tasks / git.rake
100644 28 lines (21 sloc) 0.699 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
# Sake tasks for working with Git repositories.
# svn:ignore task inspired by Chris Kaukis:
# http://rorblog.techcfl.com/2008/05/11/rails-git-and-empty-directories/
#
# Author: Patrick Reagan of Viget Labs (patrick.reagan@viget.com)
# License: MIT
#
 
namespace :git do
 
  desc "Recursively add .gitignore files to empty directories"
  task :ignore do
    root_path = File.expand_path(File.dirname(__FILE__))
    Dir.glob("#{root_path}/**").each do |path|
      if File.directory?(path)
        directory = Dir.new(path)
        files = directory.entries.reject{|entry| %w(. ..).include?(entry) }
 
 
        FileUtils.touch("#{path}/.gitignore") if files.empty?
      end
    end
 
  end
 
 
end