Add ticket number to your git commit message. This works well with Atlassian JIRA and GitHub, but is tool agnostic so you can use any tool you prefer as long it uses somewhat parseable format.
Logic:
- use ticket number from commit if one exists
- take ticket number from branch name if one exists
- either break or move along (depending on
strict
option)
This is made to work with https://pre-commit.com/ purely so you need to setup that in your environment.
- Install pre-commit
pip install pre-commit
- Create your .pre-commit-config.yaml file
- Install this hook
pre-commit install --hook-type=prepare-commit-msg
Your .pre-commit-config.yaml
could look like this:
For JIRA:
- repo: https://github.com/hanshoi/add-ticket-hook
rev: v0.1.2
hooks:
- id: add-ticket
args: ["--prefixes='TICKETNAME-,ANOTHERONE-'"]
For GitHub:
- repo: https://github.com/hanshoi/add-ticket-hook
rev: v0.1.2
hooks:
- id: add-ticket
args: ["--prefixes=#"]
-s
--strict
: Will fail if there is no ticket name and number present (default: False)-p
--prefixes
: prefixes that would correspond to ticket name