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:
@@ -38,7 +38,8 @@ WARNINGS=""
|
|||||||
|
|
||||||
# ── 1. Ruff 格式 + lint 检查 ──
|
# ── 1. Ruff 格式 + lint 检查 ──
|
||||||
if command -v ruff &> /dev/null; then
|
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
|
if [[ -n "$RUFF_OUTPUT" ]]; then
|
||||||
ERRORS+="[ruff] 风格/lint 问题:\n$RUFF_OUTPUT\n\n"
|
ERRORS+="[ruff] 风格/lint 问题:\n$RUFF_OUTPUT\n\n"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ for CODE_DIR in "${CODE_DIRS[@]}"; do
|
|||||||
|
|
||||||
# ── 1. 全量代码质量检查 ──
|
# ── 1. 全量代码质量检查 ──
|
||||||
if command -v ruff &> /dev/null; then
|
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
|
if [[ -n "$RUFF_OUTPUT" ]]; then
|
||||||
ERROR_COUNT=$(echo "$RUFF_OUTPUT" | wc -l)
|
ERROR_COUNT=$(echo "$RUFF_OUTPUT" | wc -l)
|
||||||
ERRORS+="[ruff] $CODE_DIR/ 中有 ${ERROR_COUNT} 个问题。运行 ruff check $CODE_DIR/ 查看详情。\n"
|
ERRORS+="[ruff] $CODE_DIR/ 中有 ${ERROR_COUNT} 个问题。运行 ruff check $CODE_DIR/ 查看详情。\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user