From e9d7200494a63b32a5a712de0503935f0364246d Mon Sep 17 00:00:00 2001 From: junior Date: Tue, 28 Jul 2026 15:35:35 -0400 Subject: [PATCH 1/2] fix: preserve readable staging safety chain --- .mise/tasks/obfuscate | 2 +- .mise/tasks/stage | 7 ++++ .mise/tasks/unlock | 6 ++++ README.md | 2 +- lib/hooks.sh | 67 +++++++++++++++++++++++++++++++---- lib/suppress.sh | 31 ++++++++++------ test/changes_test_helper.bash | 6 +++- test/commit.bats | 3 +- test/encrypt.bats | 22 ++++++++++++ test/obfuscate.bats | 4 +-- test/obfuscation-hooks.bats | 30 ++++++++++++++++ test/stage.bats | 48 +++++++++++++++++++++++++ test/status-suppression.bats | 17 +++++++++ 13 files changed, 221 insertions(+), 24 deletions(-) diff --git a/.mise/tasks/obfuscate b/.mise/tasks/obfuscate index 0684d3b..dea6810 100755 --- a/.mise/tasks/obfuscate +++ b/.mise/tasks/obfuscate @@ -117,7 +117,7 @@ while IFS=$'\t' read -r relpath id; do new_count=$((new_count + 1)) done < "$renamed" -git -C "$TARGET_DIR" add -- "${obfuscated_paths[@]}" +git -C "$TARGET_DIR" add --sparse -- "${obfuscated_paths[@]}" git -C "$TARGET_DIR" rm --cached --quiet --ignore-unmatch -- \ "${readable_paths[@]}" diff --git a/.mise/tasks/stage b/.mise/tasks/stage index a5178a7..0503c10 100755 --- a/.mise/tasks/stage +++ b/.mise/tasks/stage @@ -10,6 +10,7 @@ source "$MISE_CONFIG_ROOT/lib/common.sh" source "$MISE_CONFIG_ROOT/lib/obfuscate.sh" source "$MISE_CONFIG_ROOT/lib/suppress.sh" source "$MISE_CONFIG_ROOT/lib/changes.sh" +source "$MISE_CONFIG_ROOT/lib/hooks.sh" require_git notes_dir="${usage_dir:-notes}" @@ -215,6 +216,12 @@ if [ "${usage_dry_run:-}" = "true" ]; then exit 0 fi +if ! required_pre_commit_hooks_ready "$notes_dir"; then + echo "Error: required Notes pre-commit hooks are missing or stale; refusing to stage readable notes." >&2 + echo "Run 'notes install-hooks --yes', then retry." >&2 + exit 1 +fi + # Stage each file using git add -f to bypass .git/info/exclude staged=0 for relpath in ${to_stage[@]+"${to_stage[@]}"}; do diff --git a/.mise/tasks/unlock b/.mise/tasks/unlock index dbb3c1b..0dc3eec 100755 --- a/.mise/tasks/unlock +++ b/.mise/tasks/unlock @@ -5,6 +5,7 @@ set -euo pipefail source "$MISE_CONFIG_ROOT/lib/common.sh" +source "$MISE_CONFIG_ROOT/lib/hooks.sh" require_git require_initialized require_rudi @@ -35,3 +36,8 @@ if [ -f "$TARGET_DIR/notes/.manifest" ]; then cd "$MISE_CONFIG_ROOT" && NOTES_CALLER_PWD="$TARGET_DIR" mise run -q deobfuscate fi fi + +if ! required_pre_commit_hooks_ready notes; then + echo "Warning: required Notes pre-commit hooks are missing or stale." >&2 + echo "Run 'notes install-hooks --yes' before staging readable notes." >&2 +fi diff --git a/README.md b/README.md index 308a5e6..c17d2b9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ **Collective memory, encrypted.** -[![tests: 450](https://img.shields.io/badge/tests-450-brightgreen?style=flat)](test/) +[![tests: 457](https://img.shields.io/badge/tests-457-brightgreen?style=flat)](test/) ![lints: 8](https://img.shields.io/badge/lints-8-blue?style=flat) [![license: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat)](LICENSE) diff --git a/lib/hooks.sh b/lib/hooks.sh index 0094b77..bf2c8e3 100644 --- a/lib/hooks.sh +++ b/lib/hooks.sh @@ -10,13 +10,15 @@ _hook_template_value() { } _render_notes_hook_template() { - local template="${1:?usage: _render_notes_hook_template