I have a pre-commit hook that covers this (as well as much more).
The hook is available through the Git-Hub . It does not check if a Jira identifier exists, but it can verify that an identifier similar to Jira exists in a commit message. This is usually enough for developers to add Jira ticket numbers to their commit message. There is an example of a control.ini
file that shows how to check a ticket number like Jira in your commit message. Valid commit messages will be formatted as follows:
- NO: I fixed a problem in which there was no Jira ticket number
- FDS-1231: I fixed one Jira ticket
- FDS-1231, FDS-3232: I fixed several Jira tickets
However, a better way than the pre-commit trap is to change the workplace culture so that the developers naturally indicate the Jira ticket number in the commit messages and automatically give more detailed commit messages. I found that using a continuous build server such as Jenkins will do this.
Jenkins will automatically collect your code every time you register. Each assembly shows you the changes and commit comment. Jenkins integrates with Jira, so with one click you can see information about Jira. Jenkins will also attach a commit message and collect # on the Jira ticket so the quality assurance officer can look at a specific Jira ticket and see which assembly corrected that ticket.
Suddenly, commit message information becomes more visible. Developers and QA are starting to rely on this. Developers who do not add a Jira ticket are not targeted by the build guy, but by their boss and fellow developers. Posting good commit messages is now becoming a place culture. And this is much more efficient than any hook before committing.
source share