#!/bin/sh
# Auto-formats the project before every commit, using rustfmt's default
# style (no rustfmt.toml override — matches every sibling project in
# ~/dev). Tracked here rather than living only in .git/hooks/ so it's
# shareable across clones; activate once per clone with
# `cargo make install-hooks` (or `git config core.hooksPath .githooks`).
#
# Reformats the whole tree, not just staged files — simplest option for a
# single-person repo. Re-stages whatever rustfmt touched so the formatted
# version is what actually gets committed.
set -e

cargo fmt

git diff --name-only --diff-filter=M -- '*.rs' | xargs -r git add
