Adds Jira issue key as a tag in commit messages if a Jira key is found in the branch's name.
Add the following to the .pre-commit-config.yaml file in you repo.
- repo: https://github.com/ESSS/add-jira-tag-pre-commit
rev: v0.3.0
hooks:
- id: add-jira-tag
name: add-jira-tag
stages: [ prepare-commit-msg ] Then, install pre-commit hooks (usually pre-commit install).
By default the hook looks for branches named fb-{JIRA_TAG} (e.g.
fb-PROJ-123-some-feature). The prefix that precedes the Jira key is
configurable via the --prefix argument; the Jira key pattern itself
([A-Z]+-[0-9]+) is fixed.
- id: add-jira-tag
name: add-jira-tag
stages: [ prepare-commit-msg ]
args: [ "--prefix", "feat-" ]The prefix is a regex fragment, so an alternation works too — this matches
task-, feat-, or fix- branches:
args: [ "--prefix", "(task|feat|fix)-" ]
⚠️ add-jira-tagis aprepare-commit-msghook, so passing additional arguments--install-hooks -t prepare-commit-msgmay be required during hooks installation.
Run tests with:
uv run --with pytest pytestTo use this hook during development of this repo, with pre-commit:
uv run --with pre-commit pre-commit install -t prepare-commit-msgor with prek:
uv run --with prek prek install -t prepare-commit-msg