mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 14:23:16 +02:00
- Move fresh-install/ → scripts/single_use/fresh-install/ - Move hosts/ → scripts/periodic_background/hosts/ - Move i3-configuration/ → scripts/periodic_background/i3-configuration/ - Delete linux_configuration/LaTeX/, nix-poc/, report/ (dead dirs) - Move repo-root scripts/ → meta/scripts/ - Update root .pre-commit-config.yaml: scripts/ → meta/scripts/ (9 entries) - Update run.sh ARTIFACT_INIT_SCRIPT to meta/scripts/ - Update fresh-install/main.sh: hosts/install.sh + i3-configuration/install.sh paths - Update check_python_location.sh: add meta/scripts/ to exception list - Fix midnight flakiness in test_recent_workout_returns_true: use timezone-aware local noon instead of now-1h to avoid SQL date() boundary issues
55 lines
1.1 KiB
Bash
Executable File
55 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Enforce append-only semantics for session log artifacts.
|
|
|
|
set -euo pipefail
|
|
|
|
is_session_log() {
|
|
local file_path="$1"
|
|
[[ "$file_path" =~ ^docs/superpowers/sessions/.*\.(jsonl|log|txt)$ ]]
|
|
}
|
|
|
|
has_deleted_lines() {
|
|
local file_path="$1"
|
|
|
|
git diff --cached --unified=0 -- "$file_path" \
|
|
| grep -E '^-' \
|
|
| grep -Ev '^--- '
|
|
}
|
|
|
|
main() {
|
|
local staged_files
|
|
staged_files="$(git diff --cached --name-only --diff-filter=ACMR)"
|
|
|
|
local checked=0
|
|
local failures=0
|
|
|
|
while IFS= read -r file_path; do
|
|
[[ -z "$file_path" ]] && continue
|
|
if ! is_session_log "$file_path"; then
|
|
continue
|
|
fi
|
|
|
|
checked=$((checked + 1))
|
|
|
|
if has_deleted_lines "$file_path" >/dev/null; then
|
|
echo "❌ ${file_path}: append-only violation (deletions detected)"
|
|
echo " Use a new appended line instead of modifying historical entries."
|
|
failures=$((failures + 1))
|
|
fi
|
|
done <<< "$staged_files"
|
|
|
|
if (( checked == 0 )); then
|
|
echo "✓ No session logs staged"
|
|
exit 0
|
|
fi
|
|
|
|
if (( failures > 0 )); then
|
|
echo "❌ Append-only session checks failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Append-only session checks passed"
|
|
}
|
|
|
|
main "$@"
|