25 lines
1.0 KiB
Bash
Executable File
25 lines
1.0 KiB
Bash
Executable File
#!/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
|