Skip to content

Commit ff7a6aa

Browse files
committed
Say when hosted rollback removes go.work.sum
The docs said rollback deletes a go.work.sum "the pin alone created". Hosted mode keeps no record of which files existed before a pin, so it deletes any go.work.sum that stripping the Socket lines leaves empty, including one a user created empty. go never writes an empty go.work.sum, so that only happens to a file made empty by hand. Say so, rather than claim rollback can tell the cases apart. Assisted-by: Claude Code:claude-opus-5-5
1 parent 125d989 commit ff7a6aa

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎crates/socket-patch-core/src/patch/redirect/upstream/golang.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
//! beside a go.mod directive (its pin pruned it there); for a go.work
1313
//! directive, which prunes nothing, only when no sum file holds it, into
1414
//! each that held the socket pair, else go.work.sum. A go.work.sum left
15-
//! empty was created for the pin and is removed.
15+
//! empty is removed: nothing records whether it existed before the pin,
16+
//! and go never writes an empty one, so the pin almost always created it.
1617
//!
1718
//! A directive the hosted run took over from the user (a pre-existing
1819
//! `replace` it superseded) is not recorded anywhere, so the restore always
@@ -225,7 +226,7 @@ pub(crate) async fn restore(
225226
if view.read(&file).await.ok().flatten().as_deref() == Some(text.as_str()) {
226227
continue;
227228
}
228-
// The hosted run created go.work.sum for the pin alone.
229+
// go never writes an empty go.work.sum: the pin created it.
229230
if file == GO_WORK_SUM && text.is_empty() {
230231
view.remove(&file);
231232
} else {

‎docs/ecosystems.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,9 @@ source `go.work`, hosted pins checked against `go.work.sum`), `remove` and
15911591
`vendor --revert` drop the replace from `go.work` byte for byte (the vendored
15921592
ledger records the wiring file as `go.work`), and `rollback` of a hosted pin
15931593
removes the `go.work` replace and the Socket lines of `go.work.sum`, deletes a
1594-
`go.work.sum` the pin alone created, and puts the upstream pair back only
1594+
`go.work.sum` those lines leave empty (hosted mode keeps no record of whether
1595+
the file existed before the pin; go never writes an empty one, so only a
1596+
`go.work.sum` you created empty yourself is lost), and puts the upstream pair back only
15951597
where no sum file still holds it (a member's `go.mod` pin rolled back with it
15961598
gets the pair back in that member's `go.sum`, as every `go.mod` pin does). A committed workspace `vendor/` directory
15971599
needs `go work vendor` after any of these

0 commit comments

Comments
 (0)