Skip to content

Conversation

@pkage
Copy link

@pkage pkage commented Jun 13, 2025

Added experimental support for git hooks as specially named tasks:

[scripts]

lint = "uvx ruff check"
git-hook-pre-commit = ["lint"]

Running ds with the --sync-git-hooks flag will discover a .git repository in your current repository (or parent repos) and install / update all hooks defined in your config into the .git/hooks/ directory. Arguments will be passed as normal to tasks.

This feature is experimental and opt-in, mostly because I can't figure out a good way to always keep the .git/hooks/ directory in sync with the task listing. The problem is that if you install a hook and then remove all hooks from the task listing: this looks identical to never having the hooks installed at all, and syncing the hooks stomps on all the installed hooks from other tools if you have them. I toyed with the idea of adding a separate config section for hooks specifically, but that ended up being awkward to implement with all the supported task config formats.

This branch ships with full unit tests and 100% code coverage (outside the pre-existing miss on runners.py 115-118), as well as docs/readmes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant