This repo contains custom git hooks we use at Two. To add a hook to a repo you
have to add it to the repo's .pre-commit-config.yaml
file
First make sure you have installed pre-commit in your repo with brew install pre-commit
and installed the relevant hooks with pre-commit install --hook-type <type>
. See stages
in
.pre-commit-hooks.yaml for relevant hook types. For
more information on pre-commit usage, refer to
docs.
To only check for a reference to a Linear issue in your commit message, add this:
# .pre-commit-config.yaml
- repo: https://github.com/two-inc/git-hooks.git
rev: 24.11.29
hooks:
- id: linear-ref
To check for both a reference to a Linear issue as well as a conventional
commit type (<Linear ref>/<conventional commit type>[!]: <description>
), add
this:
# .pre-commit-config.yaml
- repo: https://github.com/two-inc/git-hooks.git
rev: 24.11.29
hooks:
- id: commit-type-with-linear-ref
Alternatively, you can use ssh
# .pre-commit-config.yaml
- repo: git@github.com:two-inc/git-hooks.git
rev: 24.11.29
hooks:
- id: commit-type-with-linear-ref
source venv/bin/activate
python3 -m venv venv
pip3 install -e '.[dev]'
- If you have permission to push to main directly, skip to step 2. Otherwise create a new Linear ticket with a title "git-hooks release X.Y.Z" and a new branch based on that Linear ticket branching off of main.
- Run
bumpver update --dry
to check version update will be as expected. - Run
bumpver update
to update git-hooks version. This creates a bump commit. - Push directly to
main
if you have permission to do so or via a PR if not. - Check out
main
branch and set tag withgit tag X.Y.Z
based on CalVer convention. - Push tags with
git push --tags
. - Go to GH and draft a new release - choose tag and select "generate release notes".