Skip to content

Commit faa15c7

Browse files
committed
vendor --revert restores hosted pins a pre-v5 vendor ledger re-creates
A package vendored over hosted wiring before v5 recorded the hosted fragment as its pre-vendor original, so reverting it wired the lock back to the patch server. After a wet revert, any hosted pin on a reverted purl is restored to its upstream registry entry (warning vendor_revert_restored_upstream; a refused restore is a failed event, hosted_restore_failed, exit 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tncU7u7FK48tubFNA12UQ
1 parent e62ce75 commit faa15c7

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

  • crates/socket-patch-cli/src/commands

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,6 +3353,56 @@ async fn run_revert(args: &VendorArgs, env: &mut Envelope) -> i32 {
33533353
}
33543354
}
33553355

3356+
// `--revert` returns to UPSTREAM: a package vendored over hosted wiring
3357+
// before v5 recorded the hosted fragment as its pre-vendor original, so
3358+
// its revert just wired it back to the patch server. Restore those pins
3359+
// to their upstream registry entries too (a wet run only — a dry revert
3360+
// wrote nothing to inspect).
3361+
if !common.dry_run {
3362+
let reverted: HashSet<String> = env
3363+
.events
3364+
.iter()
3365+
.filter(|e| e.action == PatchAction::Removed)
3366+
.filter_map(|e| e.purl.as_deref().map(canonical_purl))
3367+
.collect();
3368+
let rehosted: Vec<HostedPin> =
3369+
HostedPin::all(&crate::commands::discover_wiring(common, &common.cwd).await)
3370+
.into_iter()
3371+
.filter(|pin| reverted.contains(&canonical_purl(&pin.purl)))
3372+
.collect();
3373+
if !rehosted.is_empty() {
3374+
let leg = crate::commands::rollback::run_hosted_leg(common, &rehosted).await;
3375+
for purl in &leg.reverted {
3376+
record_warning(
3377+
env,
3378+
purl,
3379+
&VendorWarning::new(
3380+
"vendor_revert_restored_upstream",
3381+
format!(
3382+
"{purl} was vendored over a hosted pin before v5, so its revert \
3383+
re-wired it to the hosted patch server; restored its upstream \
3384+
registry entry"
3385+
),
3386+
),
3387+
common,
3388+
);
3389+
}
3390+
for (purl, why) in &leg.failed {
3391+
has_errors = true;
3392+
env.record(
3393+
PatchEvent::new(PatchAction::Failed, purl.clone())
3394+
.with_error("hosted_restore_failed", why.clone()),
3395+
);
3396+
}
3397+
for (code, detail) in &leg.warnings {
3398+
env.warnings.push(RunWarning {
3399+
code: code.clone(),
3400+
detail: detail.clone(),
3401+
});
3402+
}
3403+
}
3404+
}
3405+
33563406
// Orphan sweep: uuid dirs on disk with no ledger entry (a hand-edited
33573407
// state file, or artifacts left by an interrupted run). Unparseable dirs
33583408
// are reported, never deleted — and neither are dirs a lockfile still

0 commit comments

Comments
 (0)