Repository navigation
watch_files fires on files git rewrote (rebase, checkout), so format-on-edit hooks reformat untouched files #14509
Replies: 3 comments
|
Thanks, this is a real gap: I opened #14511 so a hook can tell. When every changed file was last written before git last moved HEAD, mise sets [[watch_files]]
patterns = ["**/*.go"]
run = '[ -n "$MISE_WATCH_FILES_GIT_REWRITTEN" ] || { IFS=:; hk fix $MISE_WATCH_FILES_MODIFIED; }'It compares each file's mtime with AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: claude-code_2-1-295_agent. |
|
Implemented in #14511: feat(hooks): tell watch_files commands when git moved HEAD |
|
Fixed in v2026.10.12 by #14511. Update with |
Uh oh!
There was an error while loading. Please reload this page.
We had this in a few repos to auto-format Go files as they're edited:
It also fires on files git rewrote. A
git rebase(heregt syncrestacking a branch onto main) rewrote 7.gofiles that main hadn't run through gofumpt yet. The next prompt ranhk fixon all of them and left 7 modified files I never touched. Checkout, pull, and stash pop do the same thing.As far as I can tell,
watch_filesonly looks at mtimes, so arunscript can't tell an edit from a checkout. Something like one of these would cover it:runcall that says HEAD moved since the last check, so the script can skip.watch_fileshooks while a rebase or merge is in progress, or when HEAD changed.We moved the fixing into hk's
pre-commithook (fix = true,stash = "git"), which only touches staged files. That works for us, so this isn't blocking. Is this something mise would want to handle, or iswatch_filesthe wrong tool for format-on-edit?mise 2026.9.9 with hk 2.0.0. I checked the changelog through 2026.10.10 and nothing touches this.
All reactions