Skip to content

Commit

Permalink
chore: add git (local env) prehook
Browse files Browse the repository at this point in the history
but not auto setup
  • Loading branch information
junha-ahn committed Jul 7, 2023
1 parent 724b4ac commit e791f65
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

echo "prepare-commit-msg hook script is running"

commit_template_file=$(git config commit.template)

if [ -z "$commit_template_file" ]; then
echo "Commit template is not configured. Please set the commit.template configuration."
exit 1
fi

commit_msg_file="$1"
commit_msg_type="$2"
commit_msg="$3"

if [ "$commit_msg_type" = "-m" ]; then
echo "$commit_msg" > "$commit_msg_file"
fi

commit_msg=$(cat "$commit_msg_file")

commit_msg_regex=$(cat "$(dirname "$0")/../../.github/commit-regular.txt")

if ! echo "$commit_msg" | grep -Eq "$commit_msg_regex"; then
echo "Invalid commit message format."
echo
cat "$commit_template_file"
echo
exit 1
fi

0 comments on commit e791f65

Please sign in to comment.