#!/bin/sh

set -eu

allowed_commit_types="build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test"
commit_message=$(cat "$1")
commit_type=$(echo "$commit_message" | sed -n 's/^\([a-z]*\)(.*/\1/p')

if echo ", $allowed_commit_types," | grep -q ", $commit_type,"; then
    exit 0
else
    echo "Error: Invalid commit type. Allowed types are: $allowed_commit_types"
    exit 1
fi

exit 0
