Commit 5ddf6cc
authored
fix(patch): keep the update marker on a no-op commit so a retry finalizes (#9567)
A conflicted `npm patch update` leaves an edit dir and a
`.npm-patch-update.json` marker that the finalizing `npm patch commit`
reads to finish the update — a metadata-only finalize that drops the
renamed-from selector and tolerates the new version not being installed
yet.
`commit()` deleted that marker before checking whether the edit dir
produced a diff. So a first commit that did no net work — the conflict
resolved to the new version verbatim, giving "nothing to commit" —
consumed the marker. A corrected retry then found none, ran a full
reify, and failed `EPATCHUNUSED` (the rebased-to version isn't
installed), leaving both the old and new selector in the manifest. The
same loss happened on any non-finalizing path (e.g. the `EPATCHUNSAFE`
throw).
## Fix
The marker was deleted eagerly only to keep it out of the generated
patch. Instead, keep it and teach `diffDirs` to skip it:
- `diffDirs(originalDir, editedDir, ignore = new Set())` skips a set of
root-relative filenames, like it already skips the root `package.json`.
- `commit()` no longer deletes the marker — it reads/parses it (still
throwing `EPATCHBADMARKER` on bad JSON before any diff), and passes `new
Set([UPDATE_MARKER])` to `diffDirs`.
The marker now survives any non-finalizing path, so a corrected retry
still finalizes. A successful commit removes the whole edit dir (unless
`--keep-edit-dir`), so nothing lingers.
## References
Fixes #9566
Follow-up to #9439 (native dependency patching).1 parent 1db885c commit 5ddf6cc
3 files changed
Lines changed: 45 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
242 | | - | |
243 | | - | |
244 | 243 | | |
245 | 244 | | |
246 | 245 | | |
| |||
253 | 252 | | |
254 | 253 | | |
255 | 254 | | |
256 | | - | |
| 255 | + | |
257 | 256 | | |
258 | 257 | | |
259 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
651 | 687 | | |
652 | 688 | | |
653 | 689 | | |
| |||
0 commit comments