# Read parameters
COMMIT_MSG_FILE=$1

# Set failing on command fail, and undefined variable use
set -eu

# This hook is invoked by git-commit and git-merge, and can be
# bypassed with the --no-verify option. It takes a single
# parameter, the name of the file that holds the proposed commit
# log message.

# Exiting with a non-zero status causes the command to abort.

# The hook is allowed to edit the message file in place, and can
# be used to normalize the message into some project standard format.
# It can also be used to refuse the commit after inspecting the
# message file.

# The default commit-msg hook, when enabled, detects duplicate
# Signed-off-by trailers, and aborts the commit if one is found.

# We use this hook to run "commitlint", that verifies that the
# message sent has the correct format for the project, aborting otherwise.

# Show welcome message
echo "**************************"
echo "Linting the commit message"
echo "**************************"
echo ""

# Run commitlint
npx --no -- commitlint --edit ${1}
