fix: hook scripts misread ruff success banner as a lint issue

ruff check prints 'All checks passed!' on success, which the non-empty
output test counted as one problem and blocked every commit. Use
--quiet --output-format concise so success is silent and each
diagnostic is exactly one line.
This commit is contained in:
2026-07-20 01:26:23 -04:00
parent 4f2c149a9d
commit 0df4d365a5
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ for CODE_DIR in "${CODE_DIRS[@]}"; do
# ── 1. 全量代码质量检查 ──
if command -v ruff &> /dev/null; then
RUFF_OUTPUT=$(ruff check "$CODE_DIR" 2>&1 || true)
# --quiet: 成功时零输出(避免把 "All checks passed!" 误判为问题),失败时只打印诊断行
RUFF_OUTPUT=$(ruff check --quiet --output-format concise "$CODE_DIR" 2>&1 || true)
if [[ -n "$RUFF_OUTPUT" ]]; then
ERROR_COUNT=$(echo "$RUFF_OUTPUT" | wc -l)
ERRORS+="[ruff] $CODE_DIR/ 中有 ${ERROR_COUNT} 个问题。运行 ruff check $CODE_DIR/ 查看详情。\n"