Sha256: 0eb7a189254a526a24b3f3293c88a66b51ab9e03e80c43ace4ebbe4090acdb0f

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

Dir.chdir(File.dirname(__FILE__) + "/..")

require 'pathname'
require 'rubygems'
require 'smallcage'

task :default => :smcupdate

task :smcupdate do
  system "smc update"
end

def load_svnignores(loader, path)
  dirs = loader.load_dirs(Pathname.new(path) + "child_dummy") # TODO
  ignores = []
  dirs.reverse.each do |d|
    data = d["svnignore"]
    next if data.to_s.empty?
    ignores << data
    last if d["svnignore_reset"]
  end
  data = dirs.last["svnignore_current"]
  unless data.to_s.empty?
    ignores << data
  end
  
  ignores.flatten!
  ignores.uniq!
  ignores.sort!
  return ignores
end

def set_svnignore(dryrun = false)
  loader = SmallCage::Loader.new(".")
  
  exec_svn(loader, ".", dryrun)
  Dir.glob("**/") do |f|
    exec_svn(loader, f, dryrun)
  end
end

def exec_svn(loader, f, dryrun)
  return if f =~ %r{^_smc/}
  svnignores = load_svnignores(loader, f).join("\n")
  return if svnignores.empty?
  cmd = "svn propset svn:ignore '#{svnignores}' #{f}"
  puts cmd
  return if dryrun
  puts "FAILED: #{cmd}" unless system cmd
end

# _dir.smc 
#   svnignore: *.html # set recursively.
#   svnignore_current: .project # add only current dir. 
#   svnignore_reset: true # ignore parent directory settings.
#   
# You can use list.
#   svnignore:
#     - *.html
#     - *.xml
desc "svn propset svn:ignore ..."
task :svnignore do
  set_svnignore
end

desc "confirm svn commands."
task :svnignore_dryrun do
  set_svnignore(true)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smallcage-0.1.1 project/rake/_smc/Rakefile
smallcage-0.1.2 project/rake/_smc/Rakefile