Skip to content

Instantly share code, notes, and snippets.

@rpbaltazar
Last active May 24, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpbaltazar/969206aa33617325d985b1daf1c0d8eb to your computer and use it in GitHub Desktop.
Save rpbaltazar/969206aa33617325d985b1daf1c0d8eb to your computer and use it in GitHub Desktop.
githooks examples
init:
find .git/hooks -type l -exec rm {} \;
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=[$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_])?[0-9]+' | grep -Eo '(\w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")]
if [[ $TICKET == "[]" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$TICKET $MESSAGE" > $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment