Skip to content

Fix hooks uninstall with custom core.hooksPath - #174

Open
Omer26-26 wants to merge 5 commits into
prooflinedev:mainfrom
Omer26-26:codex/fix-uninstall-hooks-path
Open

Omer26-26 wants to merge 5 commits into
prooflinedev:mainfrom
Omer26-26:codex/fix-uninstall-hooks-path

Conversation

@Omer26-26

@Omer26-26 Omer26-26 commented Dec 6, 2026 •

Copy link
Copy Markdown

Problem

hooks install writes scripts to the repository's own Git hooks directory. If core.hooksPath is configured later, hooks uninstall follows that path instead: the installed scripts remain and a shared hook directory may be modified.

Change

  • Resolve the repository-owned hooks directory from the absolute Git common directory, independent of core.hooksPath. Strip only Git's output line ending, preserving trailing spaces in valid paths.
  • When a custom hooks path is configured, tell the user to remove any manually added Proofline invocation from that tool's hook.
  • Before installing or uninstalling, resolve the default hooks directory and refuse automatic changes if it points outside the repository's Git directory. Direct users to manual setup or cleanup for externally owned hook directories.
  • Add regression tests for a Husky-style shared hook directory, linked worktrees, trailing spaces in Git's path output, and a symlinked hooks directory (Unix, with and without core.hooksPath).

Fixes #167.

Reproduce and verify

  1. In a temporary Git repository, run proofline hooks install. Confirm .git/hooks/pre-commit and .git/hooks/pre-push exist.
  2. Copy the installed pre-commit script to .husky/pre-commit, then run git config core.hooksPath .husky.
  3. Run proofline hooks uninstall. Confirm the repository-owned scripts are gone, .husky/pre-commit is untouched, and the CLI prints manual cleanup guidance for the custom path.
  4. Repeat uninstall from a linked worktree and confirm the scripts in the shared Git common directory are removed.
  5. On Unix, replace .git/hooks with a symlink to an external shared directory; install writes nothing there, and uninstall leaves it untouched with and without core.hooksPath.

Automated checks on Windows:

  • cargo +stable fmt --check — passed.
  • cargo +stable test --test hooks uninstall_ — all three applicable uninstall tests passed.
  • cargo +stable test --lib git_common_dir_keeps_trailing_spaces — passed.
  • The Unix-only symlink regression test is included but could not run on this Windows host.
  • The full hooks test suite had 6 passing tests, 1 ignored test, and 1 failing existing test (a_push_reviews_the_branches_it_updates_and_skips_tags_and_deletions). The failing test also fails on an unchanged checkout: its local bare push remote is rejected as not naming a hosted repository.

Proofline feedback

I installed Proofline on my own fork and ran a PR review. It found two real edge cases: trim() could remove a trailing space in the Git directory name, and a symlinked .git/hooks could point outside the repository. I addressed both in 0db9391 and added tests. A follow-up review pointed out that the Unix symlink test covered only a configured core.hooksPath; 4d81210 now runs that test with the setting both present and absent. I kept shared hook files under manual ownership rather than deleting them automatically.

The follow-up review also found that install could still write through an external symlink while uninstall refused to remove it. Commit 9f5ddae now applies the same containment check to both operations and adds an install regression test. Review run 3 completed on 9f5ddae with no findings.

@Omer26-26
Omer26-26 marked this pull request as ready for review December 6, 2026 20:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hooks uninstall works in the core.hooksPath directory instead of the one hooks install writes to

1 participant