class Ghundle::Command::ListInstalled

Lists all hooks installed in the current repo.

Public Instance Methods

call() click to toggle source
# File lib/ghundle/command/list_installed.rb, line 9
def call
  puts output.strip
end
output() click to toggle source
# File lib/ghundle/command/list_installed.rb, line 13
def output
  hook_names = Set.new

  Dir['.git/hooks/*'].each do |filename|
    File.open(filename) do |f|
      f.each_line do |line|
        if line =~ /^ghundle run (.*) \$\*/
          hook_names << $1.strip
        end
      end
    end
  end

  hook_names.sort.map do |hook_name|
    source = Source::Local.new(config.hook_path(hook_name))

    if source.exists?
      hook_description(Hook.new(source))
    else
      "Warning: Hook `#{hook_name}` does not exist".foreground(:red)
    end
  end.join("\n")
end