Skip to content

Instantly share code, notes, and snippets.

@moisseev
Created March 9, 2018 10:13
Show Gist options
  • Save moisseev/90453f0fadd39ce8e58b114baa0a9d8a to your computer and use it in GitHub Desktop.
Save moisseev/90453f0fadd39ce8e58b114baa0a9d8a to your computer and use it in GitHub Desktop.
git hook which adds the value of GH_TAGNAME from Makefile to a commit message
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
#Update to [GH_TAGNAME]
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
#!/bin/sh
BRANCH=$(git branch | grep '*' | sed 's/* //')
case $BRANCH in
backuppc-devel) PORTDIR='sysutils/backuppc-devel' ;;
rspamd-devel) PORTDIR='mail/rspamd-devel' ;;
esac
GH_TAGNAME=`sed -n -E 's/^GH_TAGNAME=[[:blank:]]+([[:xdigit:]]+)$/\1/p' $PORTDIR/Makefile`
sed -i.bak "s/\[GH_TAGNAME\]/$GH_TAGNAME/" "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment