Class: Git::Gsub::Commands::Rename
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
#args, #initialize, #run_commands
Constructor Details
This class inherits a constructor from Git::Gsub::Commands::Command
Instance Method Details
#build_command(from, to, paths = [], _options = {}) ⇒ Object
123 124 125 126 127 |
# File 'lib/git/gsub.rb', line 123 def build_command(from, to, paths = [], = {}) from, to, *paths = [from, to, *paths].map { |s| Shellwords.escape s } %[for f in $(git ls-files #{paths.join ' '} | grep #{from}); do mkdir -p $(dirname $(echo $f | sed 's/#{from}/#{to}/g')); git mv $f $(echo $f | sed 's/#{from}/#{to}/g') 2>/dev/null; done] end |
#run ⇒ Object
118 119 120 121 |
# File 'lib/git/gsub.rb', line 118 def run commands = args.map { |from, to| build_command(from, to, paths) } run_commands commands end |