Skip to content

Commit e61df3f

Browse files
committed
Merge remote-tracking branch 'origin/lock-model/2a-pnpm-readers' into lock-model/2b-pnpm-planner
2 parents 2731ef0 + a673e1b commit e61df3f

2 files changed

Lines changed: 79 additions & 1 deletion

File tree

‎crates/socket-patch-cli/tests/in_process_redirect_pnpm.rs‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,6 +3012,84 @@ async fn hosted_pnpm_file_tarball_copy_is_named() {
30123012
.await;
30133013
}
30143014

3015+
/// #2009: the registry release is a pnpm config dependency (the env
3016+
/// lockfile document) and the project document installs only a `file:`
3017+
/// copy of the same `name@version`. The scan pins the config dependency,
3018+
/// and names the project's copy with `redirect_copy_unpatched`, since a
3019+
/// VEX statement covers the release, not one install tree. Before, the
3020+
/// env pin's copy check compared trees, so the copy went unnamed.
3021+
#[tokio::test]
3022+
#[serial]
3023+
async fn hosted_pnpm_config_dependency_names_the_projects_file_copy() {
3024+
let server = MockServer::start().await;
3025+
mock_discovery(&server).await;
3026+
mock_reference(&server).await;
3027+
3028+
let tmp = tempfile::tempdir().unwrap();
3029+
let root = tmp.path();
3030+
let copy_key = format!("file:forks/{NAME}");
3031+
write_file_copy_project(
3032+
root,
3033+
&copy_key,
3034+
&format!(" resolution: {{directory: forks/{NAME}, type: directory}}\n"),
3035+
&format!("file:../../forks/{NAME}"),
3036+
);
3037+
std::fs::remove_dir_all(root.join("packages").join("a")).unwrap();
3038+
std::fs::write(
3039+
root.join("pnpm-lock.yaml"),
3040+
format!(
3041+
"---
3042+
lockfileVersion: '9.0'
3043+
3044+
importers:
3045+
3046+
.:
3047+
configDependencies:
3048+
{NAME}:
3049+
specifier: {VERSION}
3050+
version: {VERSION}
3051+
3052+
packages:
3053+
3054+
{NAME}@{VERSION}:
3055+
resolution: {{integrity: {UPSTREAM_SHA512}}}
3056+
3057+
---
3058+
lockfileVersion: '9.0'
3059+
3060+
importers:
3061+
.: {{}}
3062+
packages/b:
3063+
dependencies:
3064+
{NAME}:
3065+
specifier: file:../../forks/{NAME}
3066+
version: {copy_key}
3067+
3068+
packages:
3069+
{NAME}@{copy_key}:
3070+
resolution: {{directory: forks/{NAME}, type: directory}}
3071+
3072+
snapshots:
3073+
{NAME}@{copy_key}: {{}}
3074+
"
3075+
),
3076+
)
3077+
.unwrap();
3078+
3079+
let (code, doc) = run_hosted_json(root, &server.uri());
3080+
assert_eq!(code, Some(0), "{doc}");
3081+
let lock = std::fs::read_to_string(root.join("pnpm-lock.yaml")).unwrap();
3082+
assert!(
3083+
lock.contains(&format!("tarball: {HOSTED_URL}")),
3084+
"the config dependency is pinned: {lock}"
3085+
);
3086+
let text = doc.to_string();
3087+
assert!(
3088+
text.contains("redirect_copy_unpatched") && text.contains(&format!("`{NAME}@{copy_key}`")),
3089+
"the project's copy is named: {doc:#}"
3090+
);
3091+
}
3092+
30153093
/// The #935 workspace: member `a` depends on the registry release, member
30163094
/// `b` on the `file:` copy `copy_key` (spelled `spec` in its manifest).
30173095
fn write_file_copy_project(root: &Path, copy_key: &str, copy_entry: &str, spec: &str) {

‎crates/socket-patch-core/src/hosted/engine.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ async fn unattributed_pins(
22102210
for c in discovery.unpatched_copies.iter().filter(|c| {
22112211
c.purl == r.purl
22122212
&& c.file == r.source_file
2213-
&& c.part == r.part
2213+
&& r.part.withheld_by(c.part)
22142214
&& matches!(
22152215
c.file.file_name().and_then(|n| n.to_str()),
22162216
Some("pnpm-lock.yaml" | "shrinkwrap.yaml" | "yarn.lock")

0 commit comments

Comments
 (0)