Repository navigation
fix(package-manager): save hosted-git adds in normalized shortcut form - #12557
Conversation
`pacquet add <name>@owner/repo#sha` (and GitHub / GitLab / Bitbucket URL forms) previously saved the request verbatim. Save the resolver's shortcut form instead — `github:owner/repo#sha` — matching pnpm's saved `normalizedBareSpecifier`. The normalization runs only in the non-registry fallback (a git shorthand isn't claimed by the npm resolver, so no registry fetch happens), leaving registry ranges, `npm:` aliases, `file:`, `link:`, `workspace:`, and tarball URLs untouched.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughIn ChangesHosted-git specifier normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix pacquet add: normalize hosted-git specs to github:/gitlab:/bitbucket: shortcuts Description
Diagram
High-Level Assessment
Files changed (2)
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pacquet/crates/package-manager/src/add/tests.rs (1)
125-147: ⚡ Quick winExpand hosted-git normalization assertions to GitLab and Bitbucket.
This test currently validates only GitHub forms. Please add GitLab/Bitbucket shorthand + URL assertions so provider-specific normalization regressions are caught at unit level.
As per coding guidelines, REVIEW_GUIDE.md requires “regression-proving” tests that assert the exact saved specifier output.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pacquet/crates/package-manager/src/add/tests.rs` around lines 125 - 147, The test function normalizes_hosted_git_specifiers_to_shortcut_form currently only validates GitHub hosted git normalization. Add additional assertion blocks following the same pattern to test GitLab and Bitbucket providers, including both shorthand forms (gitlab:owner/repo, bitbucket:owner/repo) and full URLs (https://gitlab.com/owner/repo, https://bitbucket.org/owner/repo) to ensure provider-specific normalization is properly tested and regressions are caught at the unit test level.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pacquet/crates/package-manager/src/add/tests.rs`:
- Around line 125-147: The test function
normalizes_hosted_git_specifiers_to_shortcut_form currently only validates
GitHub hosted git normalization. Add additional assertion blocks following the
same pattern to test GitLab and Bitbucket providers, including both shorthand
forms (gitlab:owner/repo, bitbucket:owner/repo) and full URLs
(https://gitlab.com/owner/repo, https://bitbucket.org/owner/repo) to ensure
provider-specific normalization is properly tested and regressions are caught at
the unit test level.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: dab606d5-3deb-4afd-bc04-daae4710b593
📒 Files selected for processing (2)
pacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/add/tests.rs
Code Review by Qodo
1.
|
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit eb8aec3 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12557 +/- ##
==========================================
+ Coverage 87.97% 88.03% +0.05%
==========================================
Files 321 321
Lines 44517 44522 +5
==========================================
+ Hits 39166 39194 +28
+ Misses 5351 5328 -23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…specs normalized_save_specifier shortcutted every hosted-git URL, but the shortcut form cannot carry HTTPS userinfo, so an auth-bearing URL loses its credentials on save and the follow-up install could no longer reach the private repo. Keep auth-bearing URLs verbatim, mirroring the git resolver's normalized_bare_specifier, which preserves them rather than shortcutting. Also extend the unit test to GitLab and Bitbucket shorthand/URL forms. Addresses review feedback on #12557.
|
Code review by qodo was updated up to the latest commit 0559861 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 0559861 |
Integrated-Benchmark Report (Linux)Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.9437285296600004,
"stddev": 0.19551983535926803,
"median": 3.90895300356,
"user": 3.8020299599999996,
"system": 3.35416612,
"min": 3.65709906356,
"max": 4.257088058560001,
"times": [
3.8512968715600002,
4.052090118560001,
4.257088058560001,
3.9430026435600003,
4.20244397256,
3.87490336356,
3.80525308256,
4.05231511756,
3.74179300456,
3.65709906356
]
},
{
"command": "pacquet@main",
"mean": 3.89894119826,
"stddev": 0.17289261232932024,
"median": 3.84218280256,
"user": 3.74778326,
"system": 3.3743854199999994,
"min": 3.69165671556,
"max": 4.19680024556,
"times": [
4.103043626560001,
3.77895197156,
4.19680024556,
3.69165671556,
3.87024543156,
3.77904594656,
3.89277038256,
3.81412017356,
3.76294302056,
4.09983446856
]
},
{
"command": "pnpr@HEAD",
"mean": 2.0930718850599996,
"stddev": 0.05130893920242444,
"median": 2.09038942056,
"user": 2.7676913599999997,
"system": 2.9298991199999995,
"min": 2.01600553256,
"max": 2.16898815156,
"times": [
2.13580636856,
2.12636989156,
2.16898815156,
2.04426177256,
2.14696240256,
2.01600553256,
2.06845333256,
2.05802657556,
2.05351931456,
2.11232550856
]
},
{
"command": "pnpr@main",
"mean": 2.18117222376,
"stddev": 0.12683620744844515,
"median": 2.19130957756,
"user": 2.76707396,
"system": 2.9263640199999994,
"min": 2.02463159756,
"max": 2.39874436456,
"times": [
2.2481021065599998,
2.32257554756,
2.02463159756,
2.39874436456,
2.0490783545599998,
2.05284734656,
2.18287426156,
2.19974489356,
2.24956449956,
2.08355926556
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6484721569199999,
"stddev": 0.010466517904883696,
"median": 0.64528248582,
"user": 0.40250778,
"system": 1.31556762,
"min": 0.63523339432,
"max": 0.66373648732,
"times": [
0.63523339432,
0.64163348432,
0.65609241032,
0.65710856732,
0.63545750932,
0.66181915632,
0.66373648732,
0.64307558832,
0.64449202232,
0.64607294932
]
},
{
"command": "pacquet@main",
"mean": 0.6504525742200001,
"stddev": 0.021841259521715433,
"median": 0.64548494132,
"user": 0.37886597999999994,
"system": 1.3276716199999998,
"min": 0.62627916132,
"max": 0.7065404213200001,
"times": [
0.65148686532,
0.65175991332,
0.6421608923200001,
0.64276380832,
0.64820607432,
0.62627916132,
0.63994459632,
0.6354076403200001,
0.65997636932,
0.7065404213200001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7449588980199999,
"stddev": 0.04723111123427726,
"median": 0.73774966582,
"user": 0.44017808,
"system": 1.38425902,
"min": 0.7051229493200001,
"max": 0.8735443743200001,
"times": [
0.7051229493200001,
0.7433033613200001,
0.73599738932,
0.74298928832,
0.7249951773200001,
0.71110092132,
0.73950194232,
0.8735443743200001,
0.72780716832,
0.7452264083200001
]
},
{
"command": "pnpr@main",
"mean": 0.7507461788199998,
"stddev": 0.05081422986060521,
"median": 0.73766732682,
"user": 0.44656108000000005,
"system": 1.3936870200000002,
"min": 0.7074587933200001,
"max": 0.8638393603200001,
"times": [
0.72147992332,
0.72175449132,
0.7074587933200001,
0.7107587053200001,
0.73782543432,
0.7471671403200001,
0.8638393603200001,
0.73750921932,
0.8200317583200001,
0.7396369623200001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.50699388914,
"stddev": 0.07942485559988188,
"median": 4.49144157894,
"user": 4.0613002,
"system": 3.4354785,
"min": 4.4133682069399995,
"max": 4.62050522994,
"times": [
4.56460454894,
4.42288029194,
4.45999307494,
4.49187967394,
4.62050522994,
4.49100348394,
4.4133682069399995,
4.42249207694,
4.57460827594,
4.60860402794
]
},
{
"command": "pacquet@main",
"mean": 4.436661464039999,
"stddev": 0.043187374528634144,
"median": 4.428794595439999,
"user": 4.0140798,
"system": 3.38857,
"min": 4.3944295779399996,
"max": 4.544684806939999,
"times": [
4.40414912194,
4.44439752494,
4.44000923694,
4.4159594769399995,
4.43567911094,
4.46033027294,
4.544684806939999,
4.3944295779399996,
4.40506543094,
4.42191007994
]
},
{
"command": "pnpr@HEAD",
"mean": 2.17758763974,
"stddev": 0.07541167951331174,
"median": 2.16746003194,
"user": 2.6561902,
"system": 2.8980559,
"min": 2.07464093094,
"max": 2.31117681794,
"times": [
2.11160801594,
2.21357298494,
2.18011785294,
2.2701726289399997,
2.1391242669399997,
2.1059367509399998,
2.15480221094,
2.07464093094,
2.31117681794,
2.21472393694
]
},
{
"command": "pnpr@main",
"mean": 2.17223629074,
"stddev": 0.12312426890936187,
"median": 2.13924624844,
"user": 2.7042075,
"system": 2.9133223,
"min": 2.06717018294,
"max": 2.42721664294,
"times": [
2.1251756939399997,
2.3334800319399998,
2.1768555359399997,
2.15331680294,
2.0677222239399997,
2.0740196479399997,
2.21980704994,
2.42721664294,
2.07759909494,
2.06717018294
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4675202713200002,
"stddev": 0.012468207663605098,
"median": 1.46907348482,
"user": 1.49123922,
"system": 1.7640708799999998,
"min": 1.44744380232,
"max": 1.48928606132,
"times": [
1.47219327132,
1.44744380232,
1.4721888953200002,
1.4628413743200002,
1.47063050432,
1.46486709032,
1.44967986832,
1.4785553803200002,
1.48928606132,
1.4675164653200001
]
},
{
"command": "pacquet@main",
"mean": 1.4987985813200002,
"stddev": 0.09347978853856058,
"median": 1.47271982532,
"user": 1.47158032,
"system": 1.7674558799999995,
"min": 1.44786089032,
"max": 1.76302807332,
"times": [
1.4803141153200001,
1.76302807332,
1.4750829733200002,
1.44786089032,
1.4674712783200001,
1.4564207153200002,
1.46722238732,
1.4748781313200001,
1.4705615193200001,
1.48514572932
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7055085525200001,
"stddev": 0.021998937829892297,
"median": 0.6964550028200001,
"user": 0.39005871999999997,
"system": 1.3026556799999998,
"min": 0.68410127932,
"max": 0.75001067632,
"times": [
0.75001067632,
0.69416268132,
0.73953181932,
0.69531520632,
0.71154765532,
0.69869616832,
0.69574795632,
0.68410127932,
0.69716204932,
0.68881003332
]
},
{
"command": "pnpr@main",
"mean": 0.7086795411200001,
"stddev": 0.02109880459993417,
"median": 0.70297372132,
"user": 0.38212711999999993,
"system": 1.30751398,
"min": 0.69021024232,
"max": 0.76522793232,
"times": [
0.70052151232,
0.6969437603199999,
0.70542593032,
0.70936924932,
0.71074602732,
0.69021024232,
0.69863315232,
0.69718220132,
0.76522793232,
0.71253540332
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.2496469782600004,
"stddev": 0.06378928916905001,
"median": 3.2420981828599995,
"user": 1.9719285799999997,
"system": 2.0445194399999997,
"min": 3.18998992536,
"max": 3.4105283593599998,
"times": [
3.4105283593599998,
3.25793351436,
3.24772737636,
3.21182234536,
3.2463855363599996,
3.18998992536,
3.23781082936,
3.28610000136,
3.20886371736,
3.19930817736
]
},
{
"command": "pacquet@main",
"mean": 3.21205820936,
"stddev": 0.022790528115574055,
"median": 3.20490876636,
"user": 1.93038518,
"system": 2.0477472399999996,
"min": 3.18908647636,
"max": 3.2449258793599998,
"times": [
3.19041415436,
3.19284780336,
3.18908647636,
3.1993285503599997,
3.1949748693599997,
3.24104115236,
3.2150175163599997,
3.2449258793599998,
3.24245670936,
3.21048898236
]
},
{
"command": "pnpr@HEAD",
"mean": 0.70457514386,
"stddev": 0.013845707991883538,
"median": 0.69792999036,
"user": 0.37975378000000004,
"system": 1.33162344,
"min": 0.68759400936,
"max": 0.72910135336,
"times": [
0.7177197003600001,
0.7086975683600001,
0.6969427003600001,
0.6917705323600001,
0.69801990836,
0.72910135336,
0.72118555636,
0.69784007236,
0.69688003736,
0.68759400936
]
},
{
"command": "pnpr@main",
"mean": 0.7201095902600001,
"stddev": 0.04894990587409076,
"median": 0.7052563483600001,
"user": 0.38677558,
"system": 1.31045124,
"min": 0.68545979536,
"max": 0.8420296323600001,
"times": [
0.68545979536,
0.71421982636,
0.6912071293600001,
0.7027617853600001,
0.6909838423600001,
0.7681437253600001,
0.6905571553600001,
0.7079820993600001,
0.70775091136,
0.8420296323600001
]
}
]
} |
|
| Branch | pr/12557 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,506.99 ms(+6.63%)Baseline: 4,226.79 ms | 5,072.15 ms (88.86%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 3,249.65 ms(+8.22%)Baseline: 3,002.72 ms | 3,603.27 ms (90.19%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,467.52 ms(+10.04%)Baseline: 1,333.68 ms | 1,600.42 ms (91.70%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 3,943.73 ms(-2.29%)Baseline: 4,036.32 ms | 4,843.58 ms (81.42%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 648.47 ms(+3.31%)Baseline: 627.67 ms | 753.21 ms (86.09%) |
|
| Branch | pr/12557 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,177.59 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 704.58 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 705.51 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,093.07 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 744.96 ms |
Summary
pacquet add <name>@owner/repo#sha(and GitHub / GitLab / Bitbucket URL forms) previously saved the request topackage.jsonverbatim. pnpm saves the resolver's normalized shortcut form. This change does the same: the hosted-git request is rewritten to itsgithub:/gitlab:/bitbucket:shortcut (e.g.owner/repo#sha→github:owner/repo#sha) via the git resolver's ownHostedGit::from_url(...).shortcut(...)— the same logic that producesResolveResult::normalized_bare_specifier— matching pnpm's savednormalizedBareSpecifier.The normalization runs only in
add's non-registry fallback: a git shorthand isn't claimed by the npm resolver (parse_bare_specifierreturnsNonefor it, since//#fail the dist-tag check), so no registry fetch happens and registry ranges,npm:aliases,file:,link:,workspace:, and tarball URLs are left untouched.Scope note: this covers the aliased
add <name>@<git>form. The aliaslessadd owner/repo#shaform (where pnpm derives the alias from the resolved repo's manifest) is a separate, larger feature and is out of scope here.This is the focused, in-scope piece of #12548 — wiring the full post-resolution
updateProjectManifestinto pacquet add/update turned out to be a parity-only refactor with no functional gain and real regression risk (pacquet's resolver doesn't compute saved specs for registry deps, and pacquet's name-keyed writes are already immune to #11267), so only the genuine behavioral gap — git-shorthand normalization — is implemented.Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting. (Matchespnpm's existing
normalizedBareSpecifierbehavior; pacquet-only fix.)URL, idempotent
github:, and non-git specifiers.)Summary by CodeRabbit
Bug Fixes
Tests