AtlatestRepositoryslate
1
#!/usr/bin/env bash2
set -euo pipefail3
root=$(cd "$(dirname "$0")/.." && pwd)4
dispatch="$root/packages/slate-cli/src/slate-cli/dispatch.sgl"5
node="$root/packages/slate-cli/src/slate-cli/git/mutation.sgl"6
commands="$root/packages/slate/src/slate/commands/git.sgl"7
mode="$root/packages/slate/src/slate/modes/git-status.sgl"8
model="$root/packages/slate/src/slate/git/model.sgl"9
node_test="$root/packages/slate-cli/test/test-git-hunk-mutations.sgl"10
for file in "$dispatch" "$node" "$commands" "$mode" "$model" "$node_test"; do11
[ -f "$file" ] || { echo "SETUP-FAILED git-hunk-mutations: missing $file" >&2; exit 2; }12
done13
for verb in git/stage-hunk git/unstage-hunk; do14
rg -qF "\"$verb\"" "$dispatch" || { echo "git-hunk-mutations: missing dispatch $verb" >&2; exit 1; }15
rg -qF "\"$verb\"" "$commands" || { echo "git-hunk-mutations: missing client $verb" >&2; exit 1; }16
done17
rg -qF '(patch-hunks text side file-id)' "$node" || { echo 'git-hunk-mutations: node reconstruction missing' >&2; exit 1; }18
rg -qF '(snapshot=? expected latest)' "$node" || { echo 'mutation accepted stale snapshot' >&2; exit 1; }19
rg -qF 'GIT_INDEX_FILE=' "$node" || { echo 'git-hunk-mutations: isolated candidate index missing' >&2; exit 1; }20
rg -qF 'hunk-id: hunk-id' "$model" || { echo 'git-hunk-mutations: structured hunk request missing' >&2; exit 1; }21
if rg -qF 'patch: patch' "$model" "$commands"; then22
echo 'git-hunk-mutations: rendered patch crossed client boundary' >&2; exit 123
fi24
for family in git-select-stage: git-select-unstage:; do25
rg -qF "$family" "$mode" || { echo "git-hunk-mutations: pointer family missing $family" >&2; exit 1; }26
done27
cache=$(mktemp -d)28
log=$(mktemp)29
source "$root/scripts/lib/slate-harness.sh"30
trap 'rm -rf "$cache"; rm -f "$log"' EXIT31
if ! XDG_CACHE_HOME="$cache" sigil test slate-cli --sgl --no-color "$node_test" >"$log" 2>&1; then32
if rg -qF 'stage the exact non-first worktree hunk and unstage its exact index hunk' "$log"; then33
echo 'wrong hunk staged' >&234
fi35
cat "$log" >&2; exit 136
fi37
harness_verdict "$log" 138
if ! XDG_CACHE_HOME="$cache" sigil test slate --sgl --no-color \39
"$root/packages/slate/test/git-status-view-test.sgl" \40
"$root/packages/slate/test/git-status-model-test.sgl" \41
"$root/packages/slate/test/diff-control-test.sgl" >"$log" 2>&1; then42
cat "$log" >&2; exit 143
fi44
harness_verdict "$log" 345
echo 'PASS git-hunk-mutations: node reconstruction; atomic partial index; keyboard/pointer parity'