Skip to content

fix: add post-rebase uv-sync hook to prevent stale uv.lock after restack#300

Merged
ichoosetoaccept merged 1 commit intomainfrom
ismart/dot-471-add-post-rebase-uv-sync-hook
Apr 12, 2026
Merged

fix: add post-rebase uv-sync hook to prevent stale uv.lock after restack#300
ichoosetoaccept merged 1 commit intomainfrom
ismart/dot-471-add-post-rebase-uv-sync-hook

Conversation

@ichoosetoaccept
Copy link
Copy Markdown
Member

@ichoosetoaccept ichoosetoaccept commented Apr 12, 2026

Closes DOT-471

Summary

  • Add uv-sync hook on post-checkout, post-merge, and post-rewrite stages to both prek.toml and the generated template (project/prek.toml.jinja)
  • Add post-checkout, post-merge, post-rewrite to default_install_hook_types so prek wires up the git hook shims

Problem

When a stacked branch is restacked onto a base that changed pyproject.toml (e.g. version bump), uv.lock becomes stale. The uv-lock pre-commit hook only fires when pyproject.toml or uv.lock are in the changeset — so after rebase it skips and CI fails with a version mismatch.

Note

Users of the template need to re-run prek install after pulling this change to register the new git hook stages.

@ichoosetoaccept
Copy link
Copy Markdown
Member Author

This change is part of the following stack:

Change managed by git-spice.

@linear
Copy link
Copy Markdown

linear bot commented Apr 12, 2026

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 12, 2026

Greptile Summary

This PR adds uv-sync as a post-checkout/post-merge/post-rewrite hook to both prek.toml (this repo) and project/prek.toml.jinja (generated projects), and extends default_install_hook_types with post-merge and post-rewrite so prek installs those hooks. This ensures uv sync runs automatically after rebases (including restacks), merges, and branch switches, keeping the venv and uv.lock consistent. Both dual configs are updated in sync, as required.

Confidence Score: 5/5

Safe to merge — correct implementation with both dual configs updated and no functional issues found.

Changes are straightforward, consistent between the two config files, and technically correct. post-rewrite is the right git hook type for post-rebase scenarios (git has no post-rebase hook). No blocking issues.

No files require special attention.

Important Files Changed

Filename Overview
project/prek.toml.jinja Adds post-merge and post-rewrite to default_install_hook_types and expands the uv-pre-commit hooks block to include uv-sync running on those stages plus post-checkout.
prek.toml Mirror of the template change — post-merge and post-rewrite added to default_install_hook_types and uv-sync added with the same stages, satisfying the dual-config requirement from CLAUDE.md.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Git as Git
    participant prek as prek hooks
    participant UV as uv

    Dev->>Git: git rebase / git commit --amend
    Git-->>prek: post-rewrite (fires after rewrite)
    prek->>UV: uv sync
    UV-->>Dev: venv updated, uv.lock fresh

    Dev->>Git: git checkout / git pull (merge)
    Git-->>prek: post-checkout / post-merge
    prek->>UV: uv sync
    UV-->>Dev: venv updated, uv.lock fresh

    Dev->>Git: git commit (pre-commit stage)
    Git-->>prek: pre-commit
    prek->>UV: uv lock (lock file check)
    UV-->>Dev: uv.lock updated if pyproject.toml changed
Loading

Reviews (1): Last reviewed commit: "fix: add post-rebase uv-sync hook to pre..." | Re-trigger Greptile

@ichoosetoaccept ichoosetoaccept merged commit a2fc265 into main Apr 12, 2026
6 checks passed
@ichoosetoaccept ichoosetoaccept deleted the ismart/dot-471-add-post-rebase-uv-sync-hook branch April 12, 2026 14:32
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.

1 participant