fix(hook): align backup filename between install and uninstall to prevent data loss - #480
Merged
Merged
Conversation
…vent data loss install_hook() backed up existing non-cora hooks to 'pre-commit.bak', but uninstall_hook() looked for 'pre-commit.cora.bak' and 'pre-commit.pre-cora.bak'. Neither matched — so uninstall would delete the cora hook WITHOUT restoring the user's original, losing it forever. Fix: install now writes 'pre-commit.pre-cora.bak' (matching what uninstall searches for), and the dead 'pre-commit.cora.bak' path in uninstall is removed. Added regression test that verifies backup filename consistency.
ajianaz
force-pushed
the
fix/hook-backup-filename-mismatch
branch
from
August 4, 2026 10:47
1742e19 to
c3a6975
Compare
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.
What
Fixes a data loss bug in the pre-commit hook install/uninstall lifecycle.
Bug: Backup filename mismatch between install and uninstall
install_hook()pre-commit.bakpre-commit.pre-cora.bakuninstall_hook()pre-commit.cora.bak+pre-commit.pre-cora.bakpre-commit.pre-cora.bakonlyScenario:
cora hook install→ original hook backed up topre-commit.bakcora hook uninstall→ cora searches forpre-commit.cora.bak(not found) andpre-commit.pre-cora.bak(not found)Fix
install_hook(): changed backup filename frompre-commit.bak→pre-commit.pre-cora.bak(matches what uninstall expects)uninstall_hook(): removed deadpre-commit.cora.bakpath (never written by anyone)Why
This is silent data loss. Users who trusted
cora hook installover their existing hooks would permanently lose their configuration on uninstall. No error, no warning — just gone.Testing
cargo test --bin cora— 777 passed, 0 failed (was 776, +1 new regression test)cargo clippy --bin cora --tests -- -D warnings— cleancargo fmt --all— cleanNew test
backup_filename_is_pre_cora_bakverifies:"pre-commit.bak"(generic, was root cause)"pre-commit.cora.bak"(dead code)"pre-commit.pre-cora.bak"for both install and uninstall