42¢ glxn.net

Git commit-message hook for JIRA issue tags

Several of the projects I have been a part of the last couple of years used JIRA as an issue tracker. Additionally these projects also shared the notion that all commits made to the version control system should contain a tag telling other and future developers what issue the commit relates to. This also enables JIRA to show commits as part of the issue view, enabling for better visibility of code changes across the team.

It would on occasion happen that I forgot to add the JIRA tag in the commit message. I decided to set up a commit-message hook that would automatically prepend my JIRA issue number to any commit message made given that I am on a branch that follows the JIRA pattern syntax.

To install this hook simply save it with the name ‘commit-message’ in the ‘.git/hooks’ directory of your local repo and make sure it is executable.

The when you start work on an issue create a feature branch

$ git checkout -b JIRA-42

Any commits on this branch will automatically prepend “[JIRA-42] “ to that commits message if it is missing. It will also abort the commit if a JIRA tag is missing.

comments powered by Disqus

Moar stuffs

12 Sep 2017 Building an executable WS client using maven and metro
07 Jun 2015 Deploy an Ember app to gh-pages using npm run-script
06 Jun 2015 JSON Contract testing using unit tests to assert full stack integration across REST services
03 May 2015 simple http serve a directory from terminal
07 Jan 2014 civu, a CLI for cloning git repositories from jenkins views
06 Jan 2014 PyramidSort, a Sublime Text plugin for for reformatting text
05 Jan 2014 Git commit-message hook for JIRA issue tags
31 May 2013 hacking kitchen tiles with coffeescript
30 May 2013 Nuke, ps grep kill something
24 May 2013 mvnr: recursive mvn command runner
23 May 2013 Query By Example for JPA
22 May 2013 gitr: recursive git command runner
21 May 2013 Keeping gh-pages branch in sync with master
19 May 2013 Migrated from wordpress to jekyll and github pages
14 Aug 2012 Using Sublime Text 2 as git commit message editor
10 Mar 2012 QRGen, a small wrapper on top of ZXING for generating QRCodes in java
04 Jan 2012 My Bash PS1 with git branch info
17 Aug 2010 Making a swing project using IntelliJ IDEA GUI builder with maven, Including executable jar
01 May 2010 Using Arquillian to test against a remote jboss container from within IDEA
06 Apr 2010 WELD/CDI lightningtalk from Know IT 2010 annual conference
03 Apr 2010 Solving Sudoku using java swing and junit
01 Mar 2010 Simple CDI/WELD login example
01 Mar 2010 Implementing @RequestParam in CDI/WELD using Qualifier and InjectionPoint as @HttpParam
01 Nov 2009 Seam Maven Refimpl