PageRenderTime 54ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/bin/git-ls-gsub

https://github.com/banyan/config
Ruby | 16 lines | 9 code | 4 blank | 3 comment | 1 complexity | 6d2bab2563f1dd1e71d0ad1d4a9406a0 MD5 | raw file
  1. #! /usr/bin/env ruby
  2. # git ls-gsub <from> <to>
  3. # git ls-gsub <from> <to> <path>
  4. from, to, path = ARGV
  5. if [from, to].include?(nil)
  6. puts 'from and to must be given: git ls-gsub <from> <to>'
  7. exit
  8. end
  9. target_files = (`git ls-files #{path} | grep #{from}`).each_line.map(&:chomp)
  10. target_files.each do |file|
  11. `mv #{file} #{file.gsub from, to}`
  12. end