Module: Overcommit::HookContext

Defined in:
lib/overcommit/hook_context.rb,
lib/overcommit/hook_context/base.rb,
lib/overcommit/hook_context/run_all.rb,
lib/overcommit/hook_context/pre_push.rb,
lib/overcommit/hook_context/commit_msg.rb,
lib/overcommit/hook_context/post_merge.rb,
lib/overcommit/hook_context/pre_commit.rb,
lib/overcommit/hook_context/pre_rebase.rb,
lib/overcommit/hook_context/post_commit.rb,
lib/overcommit/hook_context/post_rewrite.rb,
lib/overcommit/hook_context/post_checkout.rb,
lib/overcommit/hook_context/prepare_commit_msg.rb,
lib/overcommit/hook_context/helpers/file_modifications.rb,
lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb

Overview

Utility module which manages the creation of HookContexts.

Defined Under Namespace

Modules: Helpers Classes: Base, CommitMsg, PostCheckout, PostCommit, PostMerge, PostRewrite, PreCommit, PrePush, PreRebase, PrepareCommitMsg, RunAll

Class Method Summary collapse

Class Method Details

.create(hook_type, config, args, input) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/overcommit/hook_context.rb', line 5

def self.create(hook_type, config, args, input)
  hook_type_class = Overcommit::Utils.camel_case(hook_type)
  underscored_hook_type = Overcommit::Utils.snake_case(hook_type)

  require "overcommit/hook_context/#{underscored_hook_type}"

  Overcommit::HookContext.const_get(hook_type_class).new(config, args, input)
rescue LoadError, NameError => error
  # Could happen when a symlink was created for a hook type Overcommit does
  # not yet support.
  raise Overcommit::Exceptions::HookContextLoadError,
        "Unable to load '#{hook_type}' hook context: '#{error}'",
        error.backtrace
end