Commit 96e571a
fix: ensure that resolved git ref matches expected sha (#439)
In npm/rfcs#525 about ignoring `integrity` values in lockfiles it was
stated:
> the sha is already what gets stored in the resolved field today
This is only true for resolutions from non-commits to commits.
A dependency like `git://...#4b559c4c663a23f988f6be5094c9a45faf6231bc`
will be stored using the same "reference" in `resolved` even when it
cloned a branch or a tag that resolved to a different sha.
The update is only done if it hasn't been resolved yet, which is already
the case if a full "commit" was specified:
https://github.com/npm/pacote/blob/4b559c4c663a23f988f6be5094c9a45faf6231bc/lib/git.js#L263-L265
This also applies to `npm ci` after reading `package-lock.json` as it
will use the same resolution.
This will compare the newly returned commit-hash with a previously set
`resolvedSha` and prevent that from happening.
Co-authored-by: pacotedev <i+pacotedev@izs.me>1 parent 91847c4 commit 96e571a
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
259 | 267 | | |
260 | 268 | | |
261 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
262 | 274 | | |
263 | 275 | | |
264 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
455 | 457 | | |
456 | 458 | | |
457 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
458 | 491 | | |
459 | 492 | | |
460 | 493 | | |
| |||
0 commit comments