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