Adding issue number to commit messages
by Tad Lamb Jr
We have a convention of naming our feature branches like feature/12345-short-description
where the 12345
is the number of the issue we are working on. It is also helpful to include that number in the commit message so that it looks something like
[12345] fixed the bugs I introduced
but it is a hassle to copy and paste the issue number each time, so I have automated it with this function that is included in my .profile
file.
function gc() {
message=$1
if [ $# -ne 0 ]; then
ticket=`git symbolic-ref --short HEAD | cut -d '/' -f2 | grep -o [\#0-9]* | tr -d "\r\n"`
git commit -m "[$ticket] $message"
else
echo "please supply a commit message"
fi
}
Now I can just type gc 'fixed the bugs I introduced'
and it adds the square brackets and issue number with no interruptions on my part to copy it into the commit message.
Subscribe via RSS