Files
karuo-ai/01_卡资(金)/金仓_存储备份/脚本/cursor_scm_healthcheck.sh
2026-07-19 00:21:46 +08:00

25 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# SCM 健康检查:未跟踪/变更过多时提示 gitignore防 Cursor +600万行崩溃
set -euo pipefail
ROOT="${1:-.}"
cd "$ROOT"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ 非 Git 仓库: $ROOT"
exit 1
fi
untracked=$(git ls-files --others --exclude-standard | wc -l | tr -d ' ')
changed=$(git status --short | wc -l | tr -d ' ')
lines=0
if [ "$untracked" -gt 0 ]; then
lines=$(git ls-files --others --exclude-standard | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}' || echo 0)
fi
echo "📊 $(basename "$(pwd)"): 变更=${changed} 未跟踪=${untracked} 未跟踪行≈${lines}"
if [ "$untracked" -gt 500 ] || [ "${lines:-0}" -gt 50000 ]; then
echo "⚠️ SCM 超载 — 常见原因: node_modules / 嵌套git备份 / 未写.gitignore"
echo " 真源: 卡若AI/01_卡资/金仓_存储备份/Cursor稳定性/SKILL.md"
git ls-files --others --exclude-standard | sed 's|/.*||' | sort | uniq -c | sort -rn | head -8
exit 2
fi
echo "✅ SCM 健康"
exit 0