Last active
March 23, 2023 16:06
-
-
Save JeffWaltzer/c6d345faf2c655b71d5126dd4e3c1fa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Put this in your ~/.git/hooks folder to auto add branch name to git commit messages. | |
| # | |
| BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | grep -oE "[A-Z]+-[0-9]+") | |
| if [ -n "$BRANCH_NAME" ]; then | |
| if ! grep -q "$BRANCH_NAME" $1 ; then | |
| echo -en "[$BRANCH_NAME] " | cat - "$1" > /tmp/out && mv /tmp/out "$1" | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment