class Git::Duet::InstallHookCommand
Constants
- HOOK
Public Class Methods
new(quiet = false)
click to toggle source
# File lib/git/duet/install_hook_command.rb, line 16 def initialize(quiet = false) @quiet = quiet end
Public Instance Methods
execute!()
click to toggle source
# File lib/git/duet/install_hook_command.rb, line 20 def execute! Dir.chdir(`git rev-parse --show-toplevel`.chomp) do dest = File.join(Dir.pwd, '.git', 'hooks', 'pre-commit') return error_hook_exists(dest) if File.exist?(dest) File.open(dest, 'w') { |f| f.puts HOOK } FileUtils.chmod(0755, dest) info("git-duet-install-hook: Installed hook to #{dest}") end 0 end
Private Instance Methods
error_hook_exists(dest)
click to toggle source
# File lib/git/duet/install_hook_command.rb, line 33 def error_hook_exists(dest) error('git-duet-install-hook: ' \ "A pre-commit hook already exists at #{dest}!") error('git-duet-install-hook: Move it out of the way first, mkay?') 1 end