Connect workflows to Git hooks
Once a task is useful from the terminal, you can ask Git to run it at a repository event. A hook binding selects an existing task; it does not create a second copy of the command.
Bind a task to a hook
Add an on.hooks binding to the task in .evin/workspace.flow:
tasks:
format:
stage: Check
description: "Check formatting before commit"
on:
hooks: [pre-commit]
run: npm run format:check
test:
stage: Test
description: "Run tests before push"
on:
hooks: [pre-push]
run: npm test
You can still run either task directly. To see what a hook target selects, invoke it manually before connecting Git:
evin run pre-commit --dry-run
evin run pre-push --dry-run
Connect Git to those targets
After reviewing the selected tasks, install or update Evin's hook shims:
evin sync --dry-run --verbose
evin sync
Evin supports pre-commit, commit-msg, and pre-push hook targets. The
installed shims invoke the matching evin run <hook> target, passing through
Git's arguments where needed. If a hook target fails, Git receives a non-zero
status and stops that operation.
Keep tasks and policy distinct
Tasks run the checks you define. Repository policy configures separate
built-in checks for things such as commit messages, staged files, branch
names, and remote restrictions. A hook can run tasks without defining those
policies; configure .evin/policy.json when you want Evin to enforce them too.
Start with one task binding and add policy as your repository needs it. The repository policy reference lists the supported options and validation behavior.
Next: run workflows in CI.