git hook
This commit is contained in:
1 parent
a6f35b375c
commit
b1613824ce
8 files changed
+200
-12
No files matched your search
@@ -3,6 +3,8 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||
cd "${ROOT_DIR}"
|
||||
# shellcheck source=_common.sh
|
||||
source "${ROOT_DIR}/.githooks/_common.sh"
|
||||
|
||||
STAGED_FILES="$(git diff --cached --name-only --diff-filter=ACMR || true)"
|
||||
if [[ -z "${STAGED_FILES}" ]]; then
|
||||
@@ -30,4 +32,18 @@ if [[ "${MODELS_CHANGED}" -eq 1 && "${MIGRATION_CHANGED}" -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if hook_should_skip; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if frontend_paths_in "${STAGED_FILES}"; then
|
||||
if ! run_frontend_typecheck "${ROOT_DIR}"; then
|
||||
echo "[pre-commit] vue-tsc 失败,已阻止提交。"
|
||||
echo "[pre-commit] 跳过前端检查: SKIP_FRONTEND_HOOKS=1 git commit"
|
||||
echo "[pre-commit] 或跳过全部 hook: git commit --no-verify"
|
||||
exit 1
|
||||
fi
|
||||
echo "[pre-commit] frontend 类型检查通过。"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user