add git hooks
This commit is contained in:
parent
218d12deb7
commit
fbabc9a415
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This hook works for branches named such as "123-description" and will add "[#123]" to the commit message.
|
||||
|
||||
# get current branch
|
||||
branchName=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
# search issue id in the branch name, such a "123-description" or "XXX-123-description"
|
||||
issueId=$(echo $branchName | sed -nE 's,([A-Z]?-?[0-9]+)-.+,\1,p')
|
||||
|
||||
# only prepare commit message if pattern matched and issue id was found
|
||||
if [[ ! -z $issueId ]]; then
|
||||
# $1 is the name of the file containing the commit message
|
||||
# sed -i.bak -e "1s/^/\n\n[$issueId]\n/" $1
|
||||
echo -e "#$issueId ""$(cat $1)" > "$1"
|
||||
# echo -e "[$issueId]\n""$(cat $1)" > "$1"
|
||||
# sed -i.bak -e "1s/^/$TRIMMED /" $1
|
||||
fi
|
Loading…
Reference in New Issue