Class: Ghundle::Command::Uninstall
- Defined in:
- lib/ghundle/command/uninstall.rb
Overview
Uninstalls the given hook from the local repository.
Instance Attribute Summary
Attributes inherited from Common
Instance Method Summary collapse
Methods inherited from Common
Constructor Details
This class inherits a constructor from Ghundle::Command::Common
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ghundle/command/uninstall.rb', line 8 def call hook_name = args.first hook_invocation = "ghundle run #{hook_name} $*\n" containing_hooks = Dir['.git/hooks/*'].map do |filename| contents = IO.read(filename) [filename, contents] if contents.include? hook_invocation end.compact if containing_hooks.empty? say "Hook #{hook_name} not installed" end containing_hooks.each do |filename, contents| say "Deleting from hook file `#{filename}`..." contents.gsub!(hook_invocation, '') File.open(filename, 'w') { |f| f.write(contents) } end end |