dulwich.hooks module

Access to hooks.

class dulwich.hooks.CommitMsgShellHook(controldir)

Bases: ShellHook

commit-msg shell hook

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

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: ShellHook

post-commit shell hook

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

class dulwich.hooks.PostReceiveShellHook(controldir)

Bases: ShellHook

post-receive shell hook

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(client_refs)

Execute the hook with given args

class dulwich.hooks.PreCommitShellHook(cwd, controldir)

Bases: ShellHook

pre-commit shell hook

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

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

Bases: 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