Repository navigation
Conversation
depValid's git case compared hosted repos with ssh({ noCommittish }) so a
definite commit pin could not dedupe onto a different SHA, but non-hosted
URLs only compared fetchSpec, which omits the hash. Self-hosted remotes
and git+file: pins then incorrectly shared one commit across edges.
Fixes npm#10249
ychampion
left a comment
There was a problem hiding this comment.
Checked 0781e2c13d against its parent bd8b33909a on Linux / Node 24.22.3.
The full Arborist npm test passes all 59 test files with 100% statement, branch, function and line coverage, plus lint and template checks. The new unit test fails on the parent at both non-hosted commit-mismatch assertions.
I also ran 56 actual CLI commands against disposable local Git repositories, with 28 consumer loads after fresh install and ci. Six mismatching-pin scenarios reproduce the wrong dependency on the parent and load the requested commit on this head: different versions, different commits with the same version, reversed root/child commits, scoped packages, prefer-dedupe, and nested installs. The resulting lockfiles retain both requested SHAs. The identical-commit control still deduplicates.
No blocking finding in the scoped change.
Summary
depValid's git case already refuses to treat two different definite commits as the same dependency when the remote is a hosted provider (hosted.ssh({ noCommittish: !reqCommit })). For non-hosted remotes it only comparedfetchSpec, which drops the#committish, so a self-hosted GitLab URL orgit+file:pin at commit A incorrectly satisfied an edge pinned to commit B.Fixes #10249
Changes
fetchSpecequality check, also requireresRepo.gitCommittish === requested.gitCommittishwhen the request is a definite 40–64 hex commit.git://, and hosted control cases.Test plan
npx tap --no-coverage test/dep-valid.jsinworkspaces/arborist(all subtests pass, including the new ones)AI disclosure
This change was prepared with AI assistance. The root cause and reproduction in #10249 were verified locally against current
latestbefore opening the PR; the unit tests encode the same cases called out in the issue body.