Repository navigation
fix(image): one-cycle pre-commit->prek compat shim + upgrade-time reference scan - #896
Merged
Merged
Conversation
The scaffold upgrade replaced .pre-commit-config.yaml wholesale, silently dropping the repo-specific global exclude: block and per-hook exclude: keys (field-validated on hyrr: the hook suite rewrote ~45 data files it must never touch and detect-private-key false-flagged PEM marker literals). The consumer owns the file, like justfile.project (#877): it joins PRESERVE_FILES, the upgrade prints a diff against the incoming template so hook-stack evolution stays visible, and a prek validate-config gate warns (non-fatally) when the preserved config would break every commit in the new image. Refs: #878
RED for #881: the image must answer 'pre-commit --version' via a prek compat shim with a stderr deprecation notice, and init-workspace --force must warn file:line when preserved files (justfile.project, .githooks/, .pre-commit-config.yaml) still invoke the retired pre-commit binary, without false positives on the config filename, pre-commit-hooks repo URLs, YAML stage names, comments, or prek itself. Refs: #881
…iles on upgrade The 0.4.0 image retired the Python pre-commit for prek (#778), but consumer files preserved on upgrade still invoke it and exit 127: field-validated on EXOPET/vault, where the preserved justfile.project precommit recipe and repo-managed .githooks scripts broke every commit. Image side: a writeShellScriptBin pre-commit shim in imageTools dispatches to prek (drop-in for run-style invocations) with a one-line stderr deprecation notice; DEPRECATED, removed in 0.5. Upgrade side: init-workspace --force scans the post-scaffold justfile.project, .githooks/ scripts and .pre-commit-config.yaml for invocation-shaped pre-commit references and warns with file:line, non-fatally, pointing at MIGRATION.md. The command-word pattern plus comment/stage-name filters keep the config filename, pre-commit-hooks repo URLs, pre-commit.com links, YAML stage names and prek from tripping it. Refs: #881
…ebang gotcha MIGRATION.md step 3 now covers the full rename surface (justfile recipes, repo-owned .githooks scripts, hook entries, CI configs), the one-cycle lifespan of the image shim (removed in 0.5) and the NixOS /bin/bash shebang gotcha in old-scaffold .githooks; CHANGELOG Unreleased Fixed entry added (mirror synced). Refs: #881
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #881. Stacked on #895 (branched from
bugfix/878-preserve-precommit-config; this PR shows only its own commits once #895 merges).Field evidence (EXOPET/vault, 0.3.5 → 0.4.0): the 0.4.0 image ships
prekonly (#778), but consumer files preserved on upgrade still invokepre-commitand exit 127 — the preservedjustfile.projectprecommit:recipe and the repo-managed.githooks/{pre-commit,commit-msg,prepare-commit-msg}hooks broke every commit in-image. Even a repaired justfile cannot save a consumer whose own hook scripts call the removed tool, so the fix has an image half and an upgrade half.Type of Change
fix-- Bug fixModifiers
!) -- This change breaks backward compatibilityChanges Made
(a) Image compat shim, one release cycle (
flake.nix,imageTools):writeShellScriptBin "pre-commit"shim that prints a one-line deprecation notice to stderr (stdout stays clean for pipelines) andexecs${prek}/bin/prek "$@"— prek is drop-in forrun-style invocations. MarkedDEPRECATED — remove in 0.5 (#881). Image-only (imageTools, notdevTools), so the dev-shell, home modules, and the parity gate are untouched.(b) Upgrade-time scan (
assets/init-workspace.sh, alongside the #877/#878 guards):init-workspace --forcescans the post-scaffoldjustfile.project, all.githooks/files, and.pre-commit-config.yamlfor invocation-shapedpre-commitreferences and warns non-fatally withfile:line, pointing atprek, the shim's one-cycle lifespan, and the MIGRATION.md checklist.pre-commitframed as a command word (start/whitespace/shell punctuation on both sides), so the.pre-commit-config.yamlfilename (leading.),pre-commit/pre-commit-hooksrepo URLs (leading/),pre-commit.comlinks (trailing.), andpreknever trip it; comment lines and YAML stage-name list items (- pre-commit) are filtered. Scanning post-scaffold state means fresh scaffolds and rsync-refreshed template hooks (which callprek) are silent by construction.Docs: MIGRATION.md upgrade-checklist step 3 rewritten — full rename surface (justfile recipes, repo-owned
.githooksbeyond the shipped three, hookentry:lines, CI configs), the shim's 0.4.x-only lifespan, and the NixOS#!/bin/bash→#!/usr/bin/env bashshebang gotcha in old-scaffold hooks.Changelog Entry
Fixed
pre-commitbinary dropped without a compat path — preserved consumer recipes and.githookscalling it break (#881)pre-commitforprek(#778), but files preserved on upgrade still invoke it and exit 127 (field-validated on a 0.3.5 → 0.4.0 consumer: the preservedjustfile.projectprecommitrecipe and repo-managed.githooksscripts broke every commit). The image now ships a deprecated one-cyclepre-commit → prekshim (stderr notice, removed in 0.5) so consumer hook scripts keep working while they migrate.init-workspace --forcescans the post-scaffoldjustfile.project,.githooks/scripts and.pre-commit-config.yamlfor invocation-shapedpre-commitreferences and warns (non-fatally) withfile:line, pointing at the MIGRATION.md rename checklist — which now also covers the NixOS#!/bin/bashshebang gotcha in old-scaffold.githooks.Testing
just test)TDD, both halves RED-committed first:
upgrade warns file:line when preserved files still invoke pre-commit (#881)RED (not ok) → GREEN; plus stock-scaffold and false-positive no-hit guards. Fullinit-workspace.batssuite: 75/75 ok.test_pre_commit_compat_shimRED against the pre-shim locally built image (exit 127: pre-commit: command not found— the exact field failure) → GREEN after rebuild.TestDevelopmentTools: 24 passed.Manual Testing Details
Full hook suite:
just precommitexit 0, 52 hooks passed, 0 failed.Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
test_pre_commit_installedno longer assertspre-commitabsence (superseded by the shim test for this one cycle); re-add the absence assertion when the shim is removed in 0.5.Refs: #881