fix(hooks): expand ~ in core.hooksPath before resolving install target#554
Merged
safishamsi merged 1 commit intoMay 2, 2026
Conversation
When a user configures core.hooksPath = ~/gitconfig/hooks in .gitconfig,
_hooks_dir() was constructing Path("~/gitconfig/hooks") without calling
expanduser(), so hooks were installed into <repo>/~/gitconfig/hooks instead
of the intended absolute path.
Add Path.expanduser() call immediately after reading the raw string from
git config, before the is_absolute() / root-relative fallback logic.
Fixes Graphify-Labs#547
rosschurchill
added a commit
to rosschurchill/graphify-super
that referenced
this pull request
Apr 27, 2026
Path("~/.git-hooks") keeps the literal tilde; .expanduser() converts it
to the real home directory so install writes to the correct location.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
When
.gitconfigsets:graphify hook installinstalls into<repo>/~/gitconfig/hooksinstead of the user's home-relative path. The tilde is treated as a literal directory name.Root cause:
_hooks_dir()builtPath(custom)from the raw git config string without calling.expanduser().Fix
Add
.expanduser()immediately after constructing the path from the config value, before theis_absolute()/ root-relative fallback:Testing
Added
test_hooks_dir_expands_tildeintests/test_hooks.py:$HOMEso~/custom_hooksresolves to a known temp directorysubprocess.runto return a tilde-formcore.hooksPath_hooks_dir()returns the fully expanded absolute pathAll 15 hook tests pass.
Fixes #547