Module: Golem::Command::ManageHooks
- Included in:
- CreateRepository, UpdateHooks
- Defined in:
- lib/golem/command.rb
Overview
Mixin for hook management.
Instance Method Summary collapse
-
#clear_hooks(repo) ⇒ Object
Remove hooks from repository (please note: this deletes old hooks).
-
#install_hooks(repo) ⇒ Object
Install hooks into repository.
Instance Method Details
#clear_hooks(repo) ⇒ Object
Remove hooks from repository (please note: this deletes old hooks).
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/golem/command.rb', line 96 def clear_hooks(repo) path = Golem::Config.repository_path(repo) Dir.entries(path + "/hooks").each do |hook| hook_src = path + "/hooks/" + hook File.delete(hook_src) if File.symlink?(hook_src) && ! File.file?(hook_src) next unless File.file?(hook_src) && File.stat(hook_src).executable? && hook[0..0] != "." File.delete(hook_src) print "Hook removed from #{hook_src}.\n" if verbose? end end |
#install_hooks(repo) ⇒ Object
Install hooks into repository.
84 85 86 87 88 89 90 91 92 |
# File 'lib/golem/command.rb', line 84 def install_hooks(repo) path = Golem::Config.repository_path(repo) Dir.entries(Golem::Config.hooks_dir).each do |hook| hook_src = Golem::Config.hook_path(hook) next unless File.file?(hook_src) && File.stat(hook_src).executable? && hook[0..0] != "." File.symlink(hook_src, path + '/hooks/' + hook) print "Hook installed from #{hook_src} to #{path}/hooks/#{hook}.\n" if verbose? end if File.directory?(Golem::Config.hooks_dir) end |