Created
June 11, 2020 19:09
-
-
Save zidizei/de80c29a5df5fa0f8e3e73a8c850956e to your computer and use it in GitHub Desktop.
Prefixes git commit messages with the current branch's ticket number.
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
# prefixes git commit messages with the current branch's ticket number, e.g. | |
# feature/TICKET-123-description => git commit -m "TICKET-123 ..." | |
function gcmb() { | |
pat='[A-Za-z]+\/([A-Za-z]+[-_][0-9]+)[-_]' | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
[[ $branch =~ $pat ]] | |
if [[ -z "$1" ]]; | |
then | |
git commit -m "${match} " --edit | |
else | |
git commit -m "${match} ${1}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment