build(git): .githooks补一个 commit-msg + commitlint

This commit is contained in:
sophie committed 2026-06-08 14:07:40 +08:00
1 parent c7f25ec8a1
commit 6057069c1c
9 files changed
+157 -12

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(git rev-parse --show-toplevel)"
cd "${ROOT_DIR}"
# shellcheck source=_common.sh
source "${ROOT_DIR}/.githooks/_common.sh"
COMMIT_MSG_FILE="${1:-}"
if [[ -z "${COMMIT_MSG_FILE}" ]]; then
echo "[commit-msg] missing commit message file path."
exit 1
fi
if [[ -f "${ROOT_DIR}/.git/MERGE_HEAD" ]]; then
exit 0
fi
if ! run_commitlint "${ROOT_DIR}" "${COMMIT_MSG_FILE}"; then
echo "[commit-msg] 提交信息不符合规范,详见 docs/convention/COMMIT_CONVENTION.md"
echo "[commit-msg] 示例: feat(auth): add SMS login support"
echo "[commit-msg] 跳过校验: git commit --no-verify"
exit 1
fi
exit 0