# This hook is called by "git commit" and can be used to modify the message before it is committed. If the exit status is non-zero, then the commit is aborted.
# If message is empty, execute cz
if [ -z "$2" ]; then
  exec < /dev/tty && npx cz --hook || true
  exit 0
fi
# If message is a release commit, skip validation
isReleaseCommit=$(grep -q '[generated by release-it]' $1 && echo 'true' || echo 'false')
echo "isReleaseCommit: $isReleaseCommit"
if [ "$isReleaseCommit" = 'true' ]; then
  echo "Skipping commit message validation because it's a release commit"
  exit 0
fi
else
  exec < /dev/tty && npx cz --hook || true
  exit 0
fi