Git hooks used with pre-commit to ensure proper jira issue linking in your commit messages.
See also: https://github.com/pre-commit/pre-commit
Works only with python version >= 3.6
A new version of pip that supports PEP-517/PEP-518 is required.
When the setup fails try updating pip.
This hook checks if the specified JIRA tag with issue number is present in the commit messages and can verify via the JRIA API if the issue number is valid.
Add this to your project's .pre-commit-config.yaml file:
repos: - repo: https://github.com/Cielquan/commit-msg-jira-hook rev: '' # Use the ref you want to point at hooks: - id: jira_commit_msg args: ["--jira-tag=<TAG>", "--verify", "--jira-url=<URL>"]
Exchange the placeholders with your actual config. <URL> may be https://jira.atlassian.com.
- Args to specify hook behavior:
--jira-tagis mandatory.--verifycan be omitted or changed to--no-verifyto disable online verification.--jira-urlis mandatory if online verification is enabled or can be omitted otherwise.
Then add a .jira.ini file to your home directory, if you want to use online verification
for the issue numbers, with the following config:
[jira] JIRA_USERNAME = <YOUR EMAIL> JIRA_TOKEN = <API TOKEN>
Get api token from here: https://id.atlassian.com/manage/api-tokens
Lastly install the hook:
$ pre-commit install -t commit-msgThis hook extracts this specified JIRA tag and the issue number from your current git branch and add them to the beginning of your commit message.
Add this to your project's .pre-commit-config.yaml file:
repos: - repo: https://github.com/Cielquan/commit-msg-jira-hook rev: '' # Use the ref you want to point at hooks: - id: jira_prepare_commit_msg args: ["--jira-tag=<TAG>"]
Exchange the placeholders with your actual config.
- Args to specify hook behavior:
--jira-tagis mandatory.--autocan be omitted or changed to--alwaysto always prepend JIRA tag to commit msg even when its already there.--deactivate-withtakes a string which, when present at the start of the commit msg, deactivates adding the JIRA tag to commit msg and removes the string from the commit msg.--no-errorsilences the error which occurs when the current branch has no JIRA tag.
Lastly install the hook:
$ pre-commit install -t prepare-commit-msgNo active maintenance is intended for this project. You may leave an issue if you have a questions, bug report or feature request, but I cannot promise a quick response time.