Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion git/index/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,21 @@ def run_commit_hook(name: str, index: "IndexFile", *args: str) -> None:
Arguments passed to hook file.

:raise git.exc.HookExecutionError:

:note:
Respects the ``core.hooksPath`` git configuration option. When set, hooks are
resolved relative to that path instead of the default ``.git/hooks`` directory.
"""
hp = hook_path(name, index.repo.git_dir)
hooks_path = index.repo.config_reader().get(
"core", "hooksPath", fallback=None
)
if hooks_path is not None:
hp = osp.join(hooks_path, name)
if not osp.isabs(hooks_path):
# Relative hooksPath is resolved against the working tree root.
hp = osp.join(index.repo.working_dir, hp)
else:
hp = hook_path(name, index.repo.git_dir)
if not os.access(hp, os.X_OK):
return

Expand Down
Loading