Skip to content

Instantly share code, notes, and snippets.

@luc-tielen
Created October 20, 2024 09:41
Show Gist options
  • Save luc-tielen/2890b3a2403ca0ad3ed15ac5470eedaf to your computer and use it in GitHub Desktop.
Save luc-tielen/2890b3a2403ca0ad3ed15ac5470eedaf to your computer and use it in GitHub Desktop.
Pre-commit hook for adding ticket to commit messages
#!/bin/bash
set -e
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | xargs python3 -c 'import sys; print("-".join(sys.argv[1].split("/")[1].split("-")[0:2]))')
echo "$TICKET: $MESSAGE" > $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment