From ed559c719ee88d10dc2ca567a002e8b1a524d93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Tue, 14 Apr 2026 21:42:46 +0200 Subject: [PATCH] Verify staged snapshot with pre-commit hook Stash unstaged changes and untracked files, then run `bin/rake` (tests, standard, mutant) against the exact tree the commit would produce. Restore the stash on exit so the working copy is left as it was regardless of outcome. Opt in per clone with `git config core.hooksPath .githooks`. --- .githooks/pre-commit | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..3a43294 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +stash_ref="" +cleanup() { + if [ -n "$stash_ref" ]; then + git stash pop --quiet "$stash_ref" || true + fi +} +trap cleanup EXIT + +if ! git diff --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then + git stash push --keep-index --include-untracked --quiet --message "pre-commit: $(date +%s)" + stash_ref="stash@{0}" +fi + +bin/rake -- 2.51.2