Last active
October 25, 2017 14:31
-
-
Save dmitryn/5005684 to your computer and use it in GitHub Desktop.
Git commit-msg hook which adds github issue number to commit message baed on current branch name.
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/sh | |
| # Adds github issue number to commit message based on current branch name. | |
| # Example: current branch '308-context-help', commit message 'fix bug', | |
| # final commit message will be '#308 fix bug' | |
| if [ "$NOPREFIX" ]; then | |
| exit 0 | |
| fi | |
| number=$(git branch | grep '*' | sed 's/* //' | cut -d'-' -f 1) | |
| if [[ "$number" =~ ^[0-9]+$ ]] ; then | |
| echo '#'"$number"' '$(cat "$1") > "$1" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment