23 lines
976 B
JavaScript
23 lines
976 B
JavaScript
|
|
#!/usr/bin/env node
|
|||
|
|
/** snapshot-decide (М6, Блок 2) — чистое ядро авто-снимка. */
|
|||
|
|
import { bashIsFloor } from './floor-decide.mjs';
|
|||
|
|
|
|||
|
|
/** Нужен ли снимок: только Bash-floor (reset --hard / rm -rf и т.п.). */
|
|||
|
|
export function snapshotNeeded(toolName, toolInput) {
|
|||
|
|
if (toolName !== 'Bash') return false;
|
|||
|
|
return bashIsFloor((toolInput && toolInput.command) || '');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Разобрать результат git-захвата. Чистое дерево (stash пуст) → ref=HEAD = УСПЕХ.
|
|||
|
|
* Реальная ошибка git → ok:false (fail-close). Различение F-S2.
|
|||
|
|
*/
|
|||
|
|
export function resolveGitState({ stashOut, headOut, error }) {
|
|||
|
|
if (error) return { ok: false, ref: null };
|
|||
|
|
const stash = String(stashOut || '').trim();
|
|||
|
|
if (stash) return { ok: true, ref: stash };
|
|||
|
|
const head = String(headOut || '').trim();
|
|||
|
|
if (head) return { ok: true, ref: head };
|
|||
|
|
return { ok: false, ref: null };
|
|||
|
|
}
|