Skip to content

Fix intent-to-add stash restore#2143

Merged
j178 merged 1 commit into
masterfrom
ita-restore
Jun 3, 2026
Merged

Fix intent-to-add stash restore#2143
j178 merged 1 commit into
masterfrom
ita-restore

Conversation

@j178
Copy link
Copy Markdown
Owner

@j178 j178 commented Jun 3, 2026

Closes #2142

Copilot AI review requested due to automatic review settings June 3, 2026 05:28
@j178 j178 added the bug Something isn't working label Jun 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (00b2520) to head (c2ca966).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2143      +/-   ##
==========================================
+ Coverage   92.39%   92.49%   +0.10%     
==========================================
  Files         122      122              
  Lines       25815    25813       -2     
==========================================
+ Hits        23853    23877      +24     
+ Misses       1962     1936      -26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@j178 j178 merged commit 9b0047f into master Jun 3, 2026
34 checks passed
@j178 j178 deleted the ita-restore branch June 3, 2026 05:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #2142 by ensuring “intent-to-add” (git add -N/--intent-to-add) file contents are preserved when prek run stashes/restores unstaged changes and a conflicted patch restore forces a rollback of hook modifications.

Changes:

  • Adds an integration test reproducing the conflicted stash-restore scenario with an intent-to-add file and validates file contents + intent-to-add status.
  • Refactors WorkTreeKeeper to restore unstaged working tree contents before re-adding intent-to-add index entries (fixing the loss-of-content case).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
crates/prek/tests/run.rs Adds a regression test for intent-to-add files surviving conflicted stash restore/rollback.
crates/prek/src/cli/run/keeper.rs Refactors worktree cleanup/restore to enforce correct restore ordering and remove the global restore keeper.

Comment thread crates/prek/src/cli/run/keeper.rs
Comment thread crates/prek/src/cli/run/keeper.rs
Comment thread crates/prek/src/cli/run/keeper.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content of "intent to add" files lost after stashed changes conflicted with changes made by hook

2 participants