Skip to content

Commit e957d76

Browse files
committed
Fix apply --check to skip consent-protected manifest entries
now calls skip_protected() in run_check() to skip packages with project patches, matching the behavior of mutating apply. This prevents --check from failing on protected packages that apply would skip, making the remedy text convergent. Updated the test to verify that --check exits 0 when protected records are present.
1 parent 0abf82a commit e957d76

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎crates/socket-patch-cli/src/commands/apply.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ async fn run_check(args: &ApplyArgs, manifest_path: &Path) -> i32 {
405405
let mut tree = manifest.clone();
406406
tree.patches
407407
.retain(|purl, _| owned_by_apply(purl) && !is_local_go(purl, &args.common));
408+
// Packages the project patched itself sit this run out, so `--check`
409+
// skips them too (it verifies only the patches `apply` would process).
410+
super::user_patches::skip_protected(&args.common, &mut tree.patches).await;
408411
// The same PnP gate `apply` runs: a PnP tree hides every npm copy, so
409412
// without it each npm patch would read as not installed and pass calm.
410413
if matches!(
@@ -1206,7 +1209,7 @@ pub(crate) async fn run_locked(
12061209
};
12071210

12081211
// Packages the project patched itself sit this run out (warned); every
1209-
// other record still applies. The read-only `--check` verifies them all.
1212+
// other record still applies.
12101213
let mut manifest = manifest;
12111214
let (user_patch_warnings, user_patch_skips) = if args.check {
12121215
Default::default()

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,15 @@ fn environment_and_read_only_checks_do_not_grant_or_require_consent() {
214214
BEFORE,
215215
"the environment grants no consent"
216216
);
217-
let (_, stdout, _) = run_with_env(
217+
let (code, stdout, _) = run_with_env(
218218
tmp.path(),
219219
&["apply", "--json", "--offline", "--check"],
220220
&[],
221221
);
222+
assert_eq!(
223+
code, 0,
224+
"--check exits 0 when protected records are skipped: {stdout}"
225+
);
222226
assert!(!stdout.contains("user_patch_conflict"), "{stdout}");
223227
}
224228

0 commit comments

Comments
 (0)