-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-commit-msg
More file actions
executable file
·27 lines (24 loc) · 1.07 KB
/
Copy pathgit-commit-msg
File metadata and controls
executable file
·27 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
#
# git commit-msg hook: reject a commit whose message isn't a valid Conventional Commit.
#
# Install:
# cp examples/git-commit-msg .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
#
# Git passes the path to the message file as $1 (usually .git/COMMIT_EDITMSG).
# commit-lint.js strips git's `#` comment lines and the verbose scissors section itself,
# so pointing straight at it is safe. Only error-level problems (bad type, malformed
# header, missing blank line) block the commit — length/style warnings do not.
# Bypass once with `git commit --no-verify` if you must.
#
# Assumes commit-lint.js is at the repo root. Change SCRIPTS_DIR if it lives elsewhere.
set -euo pipefail
SCRIPTS_DIR="${SCRIPTS_DIR:-$(git rev-parse --show-toplevel)}"
MSG_FILE="$1"
if ! node "$SCRIPTS_DIR/commit-lint.js" "$MSG_FILE"; then
echo "✗ Commit message isn't a valid Conventional Commit — commit blocked."
echo " Format: type(scope)?: description e.g. feat(auth): add token refresh"
echo " Bypass once with 'git commit --no-verify' if you really must."
exit 1
fi