Answer the question
In order to leave comments, you need to log in
How to use git hook to substitute part of the branch name in the commit message?
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1)
if [ -n "$BRANCH_NAME" ] && ! && ! ; then
sed -i.bak -e "1s/^/$BRANCH_NAME /" $1
fi
Answer the question
In order to leave comments, you need to log in
well, nothing was said about the OS, we will assume that there is a shell and cut
For example: PROJECT-777_fix_request_bugThat is, BRANCH_NAME=PROJECT-777_fix_request_bug
PROJECT_NAME=$(echo ${BRANCH_NAME} | cut -d_ -f1)
DESCRIPTION=$(echo ${BRANCH_NAME} | cut -d_ -f2-)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question