Last active
August 16, 2016 06:43
-
-
Save andreyserdjuk/8a0c0483ee3af7ff1ea65baf2831b9bd to your computer and use it in GitHub Desktop.
change commit message on branch example "feature/SPRINT-123" to message: "#SPRINT-123: commit message"
This file contains 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/sh | |
# | |
# Automatically adds branch name and branch description to every commit message. | |
# changes commit message on branch example "feature/SPRINT-123" to message: "#SPRINT-123: commit message" | |
# | |
# INSTALLATION: | |
# - copy to .git/hooks/prepare-commit-msg | |
# - run chmod 555 .git/hooks/prepare-commit-msg | |
# | |
NAME=$(git branch | grep '*' | grep -Po '\w+-\d+' | sed -r 's/(.*)/#\1/') | |
DESCRIPTION=$(git config branch."$NAME".description) | |
echo "$NAME"': '$(cat "$1") > "$1" | |
if [ -n "$DESCRIPTION" ] | |
then | |
echo "" >> "$1" | |
echo $DESCRIPTION >> "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment