Last active
October 7, 2015 13:58
-
-
Save sergeylukin/3175459 to your computer and use it in GitHub Desktop.
Git hook: prefix BRANCH name in every COMMIT
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 current branch name as a prefix for every Commit | |
# | |
# To enable this hook, rename this file to "commit-msg" and make sure it is executable | |
# | |
ticket=$(git symbolic-ref HEAD | awk -F'/' '{print $3}') | |
if [ -n "$ticket" ]; then | |
sed -i "1 s/^/$ticket: /" $1 | |
fi | |
################################## | |
# Optionally you could specify a | |
# folder that contains a subtree | |
# and prefix every commit related | |
# to it with a special prefix, and | |
# otherwise fallback to original | |
# behaviour: | |
# | |
#SHARED=0 | |
#for file in `git diff --cached --name-only`; do | |
# if [ `echo $file | cut -c 1-6` == "shared" ]; then | |
# SHARED=1 | |
# fi | |
#done | |
#if [ $SHARED == 1 ]; then | |
# sed -i "1 s/^/[subtree-shared] /" $1 | |
#else | |
# ticket=$(git symbolic-ref HEAD | awk -F'/' '{print $3}') | |
# if [ -n "$ticket" ]; then | |
# sed -i "1 s/^/$ticket: /" $1 | |
# fi | |
#fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment