From 0df4d365a5df1eb217342c3c01c96d87c70f027c Mon Sep 17 00:00:00 2001 From: iomgaa Date: Mon, 20 Jul 2026 01:26:23 -0400 Subject: [PATCH] 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. --- .claude/scripts/hooks/post-edit-quality.sh | 3 ++- .claude/scripts/hooks/pre-commit-guard.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.claude/scripts/hooks/post-edit-quality.sh b/.claude/scripts/hooks/post-edit-quality.sh index 768081a..3f7c738 100755 --- a/.claude/scripts/hooks/post-edit-quality.sh +++ b/.claude/scripts/hooks/post-edit-quality.sh @@ -38,7 +38,8 @@ WARNINGS="" # ── 1. Ruff 格式 + lint 检查 ── if command -v ruff &> /dev/null; then - RUFF_OUTPUT=$(ruff check "$FILE_PATH" 2>&1 || true) + # --quiet: 成功时零输出(避免把 "All checks passed!" 误判为问题),失败时只打印诊断行 + RUFF_OUTPUT=$(ruff check --quiet --output-format concise "$FILE_PATH" 2>&1 || true) if [[ -n "$RUFF_OUTPUT" ]]; then ERRORS+="[ruff] 风格/lint 问题:\n$RUFF_OUTPUT\n\n" fi diff --git a/.claude/scripts/hooks/pre-commit-guard.sh b/.claude/scripts/hooks/pre-commit-guard.sh index 10ea7b0..a3b1441 100755 --- a/.claude/scripts/hooks/pre-commit-guard.sh +++ b/.claude/scripts/hooks/pre-commit-guard.sh @@ -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"