Skip to content

Commit

Permalink
changed pre-commit for save a number of the issue into commit-message
Browse files Browse the repository at this point in the history
  • Loading branch information
Akhmetchanov Pavel Aleksandrovich committed May 11, 2020
1 parent b5f078b commit b9116aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/prepare-commit-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
set -- $HUSKY_GIT_PARAMS

BRANCH_NAME=$(git symbolic-ref --short HEAD)
# sample "19_blure_sensitive_text" -> "19"
BRANCH_NAME_ID_ISSUE=$(git symbolic-ref --short HEAD | sed -e 's/\([0-9]*\)[^0-9]*/\1/')

BRANCH_IN_COMMIT=0
if [ -f $1 ]; then
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1)
fi

if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
if [ -n "$BRANCH_NAME_ID_ISSUE" ] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
if [ -f $1 ]; then
BRANCH_NAME="${BRANCH_NAME/\//\/}"
sed -i.bak -e "1s@^@[$BRANCH_NAME] @" $1
sed -i.bak -e "1s@^@[#$BRANCH_NAME_ID_ISSUE] @" $1
else
echo "[$BRANCH_NAME] " > "$1"
fi
Expand Down

0 comments on commit b9116aa

Please sign in to comment.