Function: buildHookContext()

August 8, 2026 ยท View on GitHub

@plures/praxis


@plures/praxis / index / buildHookContext

Function: buildHookContext()

buildHookContext(hook, args?): GitHookContext

Defined in: src/hooks/context.ts:77

Build a GitHookContext from the current git state and hook arguments.

Each hook type gathers slightly different context:

  • pre-commit: staged files, diff stats
  • commit-msg: staged files, commit message from file arg
  • post-commit: committed files, commit SHA, commit message
  • pre-push: remote info, commits being pushed
  • post-merge: merged files
  • post-checkout: old/new HEAD, branch switch flag

Parameters

hook

GitHookName

The git hook name (e.g. 'pre-commit', 'post-commit')

args?

string[] = []

Arguments passed by git to the hook script (defaults to [])

Returns

GitHookContext

A populated GitHookContext for the given hook and git state