Skip to content

Instantly share code, notes, and snippets.

@MarkusH
Created February 16, 2015 22:07
Show Gist options
  • Save MarkusH/ac611c25d3e240d3277e to your computer and use it in GitHub Desktop.
Save MarkusH/ac611c25d3e240d3277e to your computer and use it in GitHub Desktop.
Prepends the current branch name to the commit message if the branch is named stable/\d.\d.x
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ ${branch} == stable/* ]] ; then
branch=${branch#stable/}
head -n1 .git/COMMIT_EDITMSG | grep -qP "\[\d\.\d\.x\]"
has_marker=$?
if [[ $has_marker == 0 ]] ; then
echo "[${branch}] " | cat - "${1}" > /tmp/tmpmessage
mv /tmp/tmpmessage "${1}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment