Created
July 27, 2022 21:18
-
-
Save melizeche/2296b9c48809918bd863abb5a5021b6b to your computer and use it in GitHub Desktop.
Better commit messages
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
# BRANCH_PREFIX will match everithing before the first underscore so if your branch name | |
# is ESGCA-9999_my_awesomefeature and your commit message is 'Fixes Changes Rabbits' | |
# your "final" commit message will be: 'ESGCA-9999: Fixes Changes Rabbits' | |
COMMIT_MSG_FILE=$1 | |
BRANCH_PREFIX=$(git branch | grep '*' | sed 's/* //' | cut -d _ -f 1) | |
echo "$BRANCH_PREFIX: $(cat $COMMIT_MSG_FILE)" > "$COMMIT_MSG_FILE" | |
# Copy this file in the .git/hooks/ directory of your local repo and make it executable `chmod +x prepare-commit-msg` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment