chore: 提交和推送前增加前端 TypeScript 检查
与 Docker 构建的 tsc -b 对齐,避免类型错误在服务器构建才暴露。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-3
@@ -17,18 +17,27 @@ if [ "${SKIP_TESTS:-0}" = "1" ]; then
|
||||
fi
|
||||
|
||||
python_files=()
|
||||
frontend_changed=0
|
||||
while read -r local_ref local_sha remote_ref remote_sha; do
|
||||
[ -z "$local_sha" ] && continue
|
||||
if [ "$local_sha" = "0000000000000000000000000000000000000000" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
|
||||
changed_paths="$(git diff-tree --no-commit-id --name-only -r --root "$local_sha" -- '*.py')"
|
||||
changed_paths="$(git diff-tree --no-commit-id --name-only -r --root "$local_sha")"
|
||||
else
|
||||
changed_paths="$(git diff --name-only "$remote_sha..$local_sha" -- '*.py')"
|
||||
changed_paths="$(git diff --name-only "$remote_sha..$local_sha")"
|
||||
fi
|
||||
while IFS= read -r path; do
|
||||
[ -n "$path" ] && [ -f "$path" ] && python_files+=("$path")
|
||||
[ -z "$path" ] && continue
|
||||
case "$path" in
|
||||
*.py)
|
||||
[ -f "$path" ] && python_files+=("$path")
|
||||
;;
|
||||
web/frontend/*)
|
||||
frontend_changed=1
|
||||
;;
|
||||
esac
|
||||
done <<< "$changed_paths"
|
||||
done <<< "$push_lines"
|
||||
|
||||
@@ -38,6 +47,10 @@ if [ "${#python_files[@]}" -gt 0 ]; then
|
||||
echo "[pre-push] Python 格式通过"
|
||||
fi
|
||||
|
||||
if [ "$frontend_changed" -eq 1 ]; then
|
||||
.githooks/run-frontend-tsc.sh
|
||||
fi
|
||||
|
||||
if [ "${TYPECHECK:-0}" = "1" ]; then
|
||||
echo "[pre-push] 运行 Pyright 类型检查..."
|
||||
uv run --group dev pyright
|
||||
|
||||
Reference in New Issue
Block a user