fix: backup existing hook before overwriting during install#8
Merged
doanbactam merged 1 commit intomasterfrom Apr 3, 2026
Merged
fix: backup existing hook before overwriting during install#8doanbactam merged 1 commit intomasterfrom
doanbactam merged 1 commit intomasterfrom
Conversation
17ebe5a to
f902a67
Compare
Previously, `nococli install` would unconditionally overwrite any existing hook at ~/.git-templates/hooks/commit-msg without backup. Now it detects non-nococli hooks, backs them up to .bak, and restores on uninstall. Also wires up the previously unused --force flag.
f902a67 to
bedda60
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.
Summary
commit-msghook at~/.git-templates/hooks/commit-msgis not from nococli before overwritingcommit-msg.bakbefore writing our hooknococli uninstall--forceCLI flag (skip backup, overwrite directly)Changed files
src/utils/hook.ts— addedNOCO_HOOK_MARKERSconstant andisNococliHook()detectorsrc/install.ts— backup logic beforewriteFile, respectsforceoptionsrc/uninstall.ts— restore.bakafter removing nococli hooksrc/cli.ts— passforceflag toinstall()Test plan
bunx tsc --noEmitpassesbun test— 27/27 existing tests passnococli install, verify.bakcreatednococli uninstall, verify hook restored from.baknococli installagain, verify no.bak(already nococli hook)nococli install --forcewith fake hook, verify no.bak