Skip to content

fix(hooks): skip post-checkout rebuild when HEAD doesn't move#2061

Open
vlecourt wants to merge 1 commit into
Graphify-Labs:v8from
vlecourt:fix/2060-checkout-same-head
Open

fix(hooks): skip post-checkout rebuild when HEAD doesn't move#2061
vlecourt wants to merge 1 commit into
Graphify-Labs:v8from
vlecourt:fix/2060-checkout-same-head

Conversation

@vlecourt

@vlecourt vlecourt commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • git checkout -b <new-branch> off the current HEAD sets BRANCH_SWITCH=1 even though PREV_HEAD/NEW_HEAD are identical, so the post-checkout hook launched a full graph rebuild for a switch with no underlying code change.
  • Since community detection isn't fully deterministic across runs, that produced pure reordering churn in graphify-out/graph.json, which teams ended up discarding via git stash.
  • Added an early-exit guard right after the existing BRANCH_SWITCH != 1 check: skip the rebuild when PREV_HEAD equals NEW_HEAD.

Fixes #2060

Test plan

  • uv run pytest tests/test_hooks.py -q — 61 passed (3 new tests covering the guard, static + end-to-end)
  • uv run ruff check graphify/hooks.py tests/test_hooks.py
  • uv run python -m tools.skillgen --check

git checkout -b <new-branch> off the current HEAD sets BRANCH_SWITCH=1
even though PREV_HEAD and NEW_HEAD are identical, so the post-checkout
hook launched a full graph rebuild for a switch with no underlying code
change. Since community detection isn't fully deterministic across
runs, that produced pure reordering churn in graphify-out/graph.json,
which teams ended up discarding via git stash.

Fixes Graphify-Labs#2060

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zeriss

zeriss commented Jul 20, 2026

Copy link
Copy Markdown

🎉 Awesome first PR!

Really nice improvement. I have a feeling this is going to become part of our daily workflow. Thanks for contributing this—great job!

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.

post-checkout hook rebuilds on branch creation even when PREV_HEAD == NEW_HEAD

3 participants