in #1573 we hit a large re-format, because @iwami4438 pre-commit hook ran a current ormolu (0.7.2.0) while the codebase is formatted with a much older one (my local copy turns out to be 0.1.0.0, from 2020, i think i’m old?!). ormolu changed its style between those versions, so everyone's hook fights everyone else's. the version isn't pinned, CI doesn't check formatting, and the hook reformats and stages silently, so nobody sees it happen, it just goes in the commit.
my proposal:
- we pin the ormolu version. record it in a single place (e.g.
ormolu.version at the repo root, read by scripts/format.sh, or directly in the format script). format.sh would then refuse to run if ormolu --version doesn't match, with install instructions. i'd pin to the current release rather than an old one, since that's what stack install / brew hands people. it would mean that we’d have to keep it current or force people to downgrade their ormolu, though?
- we make a one-time reformat commit: run the pinned ormolu over all the source code in a dedicated commit.
- add a CI check, just a small workflow using
haskell-actions/run-ormolu with mode: check and the pinned version. then we catch early if we stray from the path.
- we make the hook check instead of mutate (pre-commit runs
ormolu --mode check on staged files instead of just rewriting and git adding). contributors see what changes, and we don’t need to --no-verify. (the current auto-git add also breaks partial staging, which is not cool!)
wdyt?
cheers
in #1573 we hit a large re-format, because @iwami4438 pre-commit hook ran a current ormolu (0.7.2.0) while the codebase is formatted with a much older one (my local copy turns out to be 0.1.0.0, from 2020, i think i’m old?!). ormolu changed its style between those versions, so everyone's hook fights everyone else's. the version isn't pinned, CI doesn't check formatting, and the hook reformats and stages silently, so nobody sees it happen, it just goes in the commit.
my proposal:
ormolu.versionat the repo root, read byscripts/format.sh, or directly in the format script).format.shwould then refuse to run iformolu --versiondoesn't match, with install instructions. i'd pin to the current release rather than an old one, since that's what stack install / brew hands people. it would mean that we’d have to keep it current or force people to downgrade their ormolu, though?haskell-actions/run-ormoluwithmode: checkand the pinned version. then we catch early if we stray from the path.ormolu --mode checkon staged files instead of just rewriting and git adding). contributors see what changes, and we don’t need to--no-verify. (the current auto-git add also breaks partial staging, which is not cool!)wdyt?
cheers