PEP-230: проверка перед переключением считает только текущую ветку рабочей копии

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-21 18:28:08 +05:00
parent 3d4a213caa
commit 379ae6a845

View File

@ -20,13 +20,14 @@ SERVICES="bot watchdog web observer"
S true || die "сервер недоступен"
say "живых сессий агентов: $(sqlite3 -readonly "$PH/peppa.db" "select count(*) from sessions where status not in ('done','failed')")"
DIRS=$(sqlite3 -readonly "$PH/peppa.db" "select workspace_path from projects where deleted_at is null; select workspace_path from sessions where workspace_path is not null and status not in ('done','failed');" | sort -u)
LIVE=$(sqlite3 -readonly "$PH/peppa.db" "select workspace_path from projects where key = '${PEPPA_PLATFORM_KEY:-PEP}'")
LOST=0
for d in $DIRS; do
[ -d "$d/.git" ] || [ -f "$d/.git" ] || continue
[ -d "$d/scripts/server-move" ] || [ -f "$d/scripts/live-deploy.sh" ] && continue # сама платформа: её код уже в Gitea
[ "$d" = "$LIVE" ] && continue # живая копия платформы: в ней не коммитят, её код уже в Gitea
br=$(git -C "$d" branch --show-current 2>/dev/null || true)
dirty=$(git -C "$d" status --porcelain 2>/dev/null | grep -v '^?? .peppa/' | wc -l | tr -d ' ')
ahead=$(git -C "$d" log --oneline --branches --not --remotes 2>/dev/null | wc -l | tr -d ' ')
dirty=$(git -C "$d" status --porcelain 2>/dev/null | { grep -v '^?? .peppa/' || true; } | wc -l | tr -d ' ')
ahead=$(git -C "$d" log --oneline HEAD --not --remotes 2>/dev/null | wc -l | tr -d ' ')
[ "$dirty" = 0 ] && [ "$ahead" = 0 ] && continue
say "не в Gitea: $d (ветка ${br:-?}, изменённых файлов $dirty, неотправленных коммитов $ahead)"
[ "$MODE" = go ] || continue