fix: make installer idempotent and respect core.hooksPath#405
Open
voidborne-d wants to merge 1 commit intosafishamsi:v4from
Open
fix: make installer idempotent and respect core.hooksPath#405voidborne-d wants to merge 1 commit intosafishamsi:v4from
voidborne-d wants to merge 1 commit intosafishamsi:v4from
Conversation
…#401) Three problems fixed: 1. **Already-integrated repos**: now detects repos that already track integration files (.claude/settings.json, .codex/hooks.json, etc.) via `git ls-files` and no-ops with guidance instead of writing duplicate untracked files that block the next `git pull`. Pass `--force` to override. 2. **core.hooksPath (Husky compatibility)**: `graphify hook install/uninstall/ status` now reads `core.hooksPath` from git config and writes hooks there instead of always targeting `.git/hooks/`. This prevents the installer from bypassing Husky's hook directory and from accidentally unsetting `core.hooksPath` by writing duplicate hooks to the wrong location. 3. **core.bare=true guard**: `graphify hook install` now refuses to operate when `core.bare=true` is set on a working tree, preventing invalid state. Adds 18 regression tests covering: - Tracked vs untracked integration file detection - --force flag bypass - core.hooksPath resolution (absolute, relative, missing dir fallback) - Hooks written to correct directory with Husky-style config - core.bare=true rejection and false/unset acceptance Closes safishamsi#401
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.
Fixes #401
Problem
graphify installcan damage a repository that already vendors its Graphify integration:.claude/settings.json,.codex/hooks.json,.cursor/rules/graphify.mdc) that are already tracked in git, causinggit pullto fail with "would be overwritten by merge"graphify hook installalways writes to.git/hooks/, ignoringcore.hooksPath— this bypasses Husky's hook directory and can disable existingpre-commit/pre-pushhookscore.bare=trueon a working treeSolution
1. Already-integrated repo detection (
__main__.py)_is_already_integrated()function checksgit ls-filesfor known integration markers (.claude/settings.json,.codex/hooks.json,.cursor/rules/graphify.mdc, etc.)install()now no-ops with clear guidance when tracked integration files are detected--forceflag added to override the guard when the user explicitly wants to reinstall2. Respect
core.hooksPath(hooks.py)_resolve_hooks_dir()readscore.hooksPathfrom git config.git/hookswhen the configured directory doesn't existinstall(),uninstall(), andstatus()all use the resolved hooks directory.husky/_or.huskydirectory is respected — graphify hooks are written there instead of.git/hooks/3.
core.bare=trueguard (hooks.py)hook installnow checkscore.bareand refuses to proceed if it'strue, with a helpful fix suggestionTests
18 new regression tests in
tests/test_idempotent_install.py:All 18 new + 51 existing tests pass (
test_hooks.py+test_install.py+test_idempotent_install.py).