Skip to content

Commit 3d53de2

Browse files
committed
chore(git): improve git message hook
1 parent fd0d611 commit 3d53de2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.dev/githooks/prepare-commit-msg

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@
99
# message file. If the hook fails with a non-zero status,
1010
# the commit is aborted.
1111
#
12-
# To enable this hook, rename this file to "prepare-commit-msg".
12+
# To enable this hook, set the hooksPath in git:
13+
# git config core.hooksPath .dev/githooks
1314

1415
COMMIT_MSG_FILE=$1
1516
COMMIT_SOURCE=$2
1617
SHA1=$3
1718

19+
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
20+
1821
original=$(cat "$COMMIT_MSG_FILE")
19-
printf "\n\n# Please enter the message in the format\n" > "$COMMIT_MSG_FILE"
20-
echo "# <type>(<scope>): <description>" >> "$COMMIT_MSG_FILE"
21-
echo "# Possible types: fix, feat, docs, style, refactor, test, chore, rework, release" >> "$COMMIT_MSG_FILE"
22-
echo "# For details see https://www.notion.so/softwarechallenge/Git-217333329ea64db5b2cc8bbbaf79db87" >> "$COMMIT_MSG_FILE"
23-
echo "$original" >> "$COMMIT_MSG_FILE"
22+
if beginswith $'\n#' "$original"; then
23+
{
24+
printf "\n\n# Please enter the message in the format\n"
25+
echo "# <type>(<scope>): <description>"
26+
echo "# Possible types: fix, feat, docs, style, refactor, test, chore, rework, release"
27+
printf "# For details see https://www.notion.so/softwarechallenge/Git-217333329ea64db5b2cc8bbbaf79db87" >> "$COMMIT_MSG_FILE"
28+
echo "$original"
29+
} > "$COMMIT_MSG_FILE"
30+
fi

0 commit comments

Comments
 (0)