Class: Overcommit::HookLoader::PluginHookLoader

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook_loader/plugin_hook_loader.rb

Overview

Responsible for loading hooks that are specific to the repository Overcommit is running in.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Overcommit::HookLoader::Base

Instance Method Details

#load_hooksObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/overcommit/hook_loader/plugin_hook_loader.rb', line 9

def load_hooks
  check_for_modified_plugins if @config.verify_signatures?

  hooks = plugin_paths.map do |plugin_path|
    require plugin_path

    hook_name = Overcommit::Utils.camel_case(File.basename(plugin_path, '.rb'))
    create_hook(hook_name)
  end

  hooks + ad_hoc_hook_names.map do |hook_name|
    create_ad_hoc_hook(hook_name)
  end
end

#update_signaturesObject



24
25
26
27
28
29
30
31
# File 'lib/overcommit/hook_loader/plugin_hook_loader.rb', line 24

def update_signatures
  log.success('No plugin signatures have changed') if modified_plugins.empty?

  modified_plugins.each do |plugin|
    plugin.update_signature!
    log.warning "Updated signature of plugin #{plugin.hook_name}"
  end
end