Repository navigation
Feature/pre commit hooks - #857
jurretanjamx wants to merge 15 commits into
Conversation
Added pre-commit.ci status badge to README.
Added clarification on README purpose and project overview.
…talled for you install-project-hooks.sh finds or installs pre-commit (brew, pipx, uv, pip --user; never sudo; opt out with MXTK_INSTALL_PRECOMMIT=0) and writes a "# mxtk-managed" block into .pre-commit-config.yaml, so teams can keep their own hooks next to the toolkit's in one standard file. An older project moves over on its next sync-project.sh. Where pre-commit is not available, the plain hooks are written byte-identical to before. Drops the earlier toolkit-clone change on this branch (root .pre-commit-config.yaml, bin/install-hooks.sh rewrite, its fixture, the README badge): the target is the projects that use the toolkit, not the toolkit's own clone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Outside PR marker: DISCUSS — a new third-party dependency, auto-installed on every synced project, and the default hook install path changes Review: HOLD — Value
Overbuilt for an opt-in feature: a four-way installer ( Regression risk
Correctness
Context cost Time cost Exact fixes (for option 2)
Options (DISCUSS)
Generated by Claude Code |
Require an existing pre-commit installation for opt-in use, document the setup, and cover captured hook/config behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Toolkit hooks are plain Git hooks by default. To opt in to pre-commit, provision it in the developer/agent environment and set MXTK_INSTALL_PRECOMMIT=1 for init-project.sh, sync-project.sh, or install-project-hooks.sh. The toolkit does not install packages. If pre-commit is unavailable, plain hooks remain in use. The installer validates its managed config block before writing it and preserves team hooks outside that block. --check does not fail solely because pre-commit is absent, but still fails for missing managed hooks or config. pre-commit stashes unstaged changes while hooks run; save and stage model files before command-line commits. Validation: test-model-stamp.sh passed (52/52); Linux field run with pre-commit 4.7.0 passed. Git Bash validation remains outstanding. |
Keep managed hook validation failures visible when pre-commit is unavailable, and document its unstaged-file stash behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for this. One config file for team hooks and a single source for the hook bodies are both real improvements. We'd like to take it, but as an opt-in, because the toolkit runs on many projects, often driven by agents or CI with no person at the terminal. Changes we need before merge:
Optional: a quick timing of one commit with and without pre-commit, so we can state the per-operation cost. Happy to re-review once these are in. Thanks again! Generated by Claude Code |
|
Outside PR marker: HOLD — the install is now opt-in, but a clone that loses pre-commit is still locked out and sync no longer repairs it; the pre-push and stash issues remain. Review: HOLD — in pre-commit mode with pre-commit gone, Safety: no package installs, network fetches, CI edits, or hidden or bidi characters. No existing assertion was weakened.
Exact fixes remaining
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses the second MendixMau#857 review (HOLD). Each .git/hooks/<type> is now a small toolkit wrapper that calls pre-commit hook-impl, not pre-commit's generated file, so git's own input reaches the toolkit first: - pre-push checks every pushed ref, and post-rewrite notes the real rewritten commits (saved stdin, MXTK_HOOK_INPUT), not the first ref or an ORIG_HEAD..HEAD guess. - No pre-commit, no config on the branch, or no managed block: the plain toolkit hook runs with one warning. Never locked out. - --check fails while pre-commit is missing, so sync restores plain hooks. - MXTK_INSTALL_PRECOMMIT=0 switches an opted-in clone back. - pre-commit stashes in every hook stage: each wrapper compares the unstaged .mpr/mprcontents diff before and after, and on a difference prints the git apply command; commit and push are stopped. - --run skips _common.sh (hook-call cost). Plain hooks stay byte-identical to master's. T12 rewritten against a stub pre-commit (67/67); tests/retests/field-precommit-hooks.sh part A 17/17 on macOS with pre-commit 4.6.1. Linux, Git Bash and the Studio Pro part B are still to run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mmit hooks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the second review. The main change since it:
Time cost. One hook call costs about 1 s with pre-commit vs about 0.1 s plain on macOS, and about 2.9 s vs 0.55 s on Windows (20 checkouts, field run A7). Almost all of it is pre-commit's own startup and stash check. Regression risk for existing projects. Default mode is unchanged. Plain hooks are byte-identical to master's, and no clone switches without |
Here's the PR description draft:
Title: Run a project's git hooks through pre-commit, installed for you
Summary
Projects that use the toolkit get their git hooks from bin/install-project-hooks.sh:
Until now these were plain scripts in .git/hooks. A team's own hook was moved aside to .pre-mxtk and chained, and there was no standard place to add more hooks.
With this PR, the hooks run through pre-commit (https://pre-commit.com):
How it works
Known risks and limits
Also in this PR
Testing
🤖 Generated with Claude Code (https://claude.com/claude-code)