Sha256: 54a3310254fbd57c39c5df0c52c0fd1eab732569def88f8bb95ee686ab77f958

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

namespace :svn do

  # _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 :ignore do
    set_svnignore
  end

  desc "Confirm svn commands."
  task :ignore_dryrun do
    set_svnignore(true)
  end

end



def load_svnignores(loader, path)
  dirs = loader.load_dirs(Pathname.new(path) + "child_dummy") # XXX
  ignores = []
  dirs.reverse.each do |d|
    data = d["svnignore"]
    ignores << data unless data.to_s.empty?
    break 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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
smallcage-0.3.2 project/rake/_smc/rakelib/svn.rake
smallcage-0.3.1 project/rake/_smc/rakelib/svn.rake
smallcage-0.3.0 project/rake/_smc/rakelib/svn.rake
smallcage-0.2.9 project/rake/_smc/rakelib/svn.rake
smallcage-0.2.8 project/rake/_smc/rakelib/svn.rake
smallcage-0.2.7 project/rake/_smc/rakelib/svn.rake
smallcage-0.2.6 project/rake/_smc/rakelib/svn.rake
smallcage-0.2.5 project/rake/_smc/rakelib/svn.rake