module Golem::Command::ManageHooks

Mixin for hook management.

Public Instance Methods

clear_hooks(repo) click to toggle source

Remove hooks from repository (please note: this deletes old hooks). @param [String] repo repository name.

# 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) click to toggle source

Install hooks into repository. @param [String] repo repository name.

# 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