dulwich.hooks module

Access to hooks.

class dulwich.hooks.CommitMsgShellHook(controldir)

Bases: dulwich.hooks.ShellHook

commit-msg shell hook

Parameters:args[0] – commit message
Returns:new commit message or None
class dulwich.hooks.Hook

Bases: object

Generic hook object.

execute(*args)

Execute the hook with the given args

Parameters:args – argument list to hook
Raises:HookError – hook execution failure
Returns:a hook may return a useful value
class dulwich.hooks.PostCommitShellHook(controldir)

Bases: dulwich.hooks.ShellHook

post-commit shell hook

class dulwich.hooks.PreCommitShellHook(controldir)

Bases: dulwich.hooks.ShellHook

pre-commit shell hook

class dulwich.hooks.ShellHook(name, path, numparam, pre_exec_callback=None, post_exec_callback=None, cwd=None)

Bases: dulwich.hooks.Hook

Hook by executable file

Implements standard githooks(5) [0]:

[0] http://www.kernel.org/pub/software/scm/git/docs/githooks.html

Setup shell hook definition

Parameters:
  • name – name of hook for error messages
  • path – absolute path to executable file
  • numparam – number of requirements parameters
  • pre_exec_callback – closure for setup before execution Defaults to None. Takes in the variable argument list from the execute functions and returns a modified argument list for the shell hook.
  • post_exec_callback – closure for cleanup after execution Defaults to None. Takes in a boolean for hook success and the modified argument list and returns the final hook return value if applicable
  • cwd – working directory to switch to when executing the hook
execute(*args)

Execute the hook with given args