module SuperHooks # Interface with the list of hooks available class Hook # An array of existing git hooks LIST = %w( applypatch-msg commit-msg post-applypatch post-checkout post-commit post-merge post-receive pre-applypatch pre-auto-gc pre-commit prepare-commit-msg pre-rebase pre-receive update pre-push ) class << self # Find a list of hooks by applying the levels to them # # *name: the name of the path (can be partial) # *kind: the type of hook. eg: pre-commit # *level: the folder to search for hooks: [:user, :project, :global] # # Example # # # where(name: "rake", kind: ["pre-rebase", "pre-commit"], level: [:user]) # # # # => [# true # # Returns a boolean indicating if this was a successfull run def execute!(arguments = '') system("#{path} #{arguments}", out: $stdout, err: $stderr) end alias_method :run, :execute! # Get a short description of the hook # # It gets the description of the file by running the file name with the --about flag # # Example # # # description # # => "A signoff commit msg", # # Returns a string def description `#{path} --about`.chomp end end end