fix(34): WR-02 undo a failed plugin:install or plugin:update

A failure after the first change left the application half-modified: a
checkout moved into plugins/<vendor>/<name> but not registered, go.mod
edited, submodules without summer.yaml entries (and the next install
refused the leftover directory), or some submodules updated and others
not. Both commands now snapshot go.mod, go.sum, go.work, go.work.sum,
summer.yaml and .gitmodules (with its index entry) before applying; a
failure restores them, removes the submodules the run added (index
entry, submodule config, absorbed git dir, checkout; registered right
after the move) and checks moved submodules out where they were. What
cannot be undone is named in the error.
This commit is contained in:
Jakub Zych
2026-10-29 22:08:54 +01:00
parent 07673e4f30
commit 9977e31ac9
6 changed files with 301 additions and 12 deletions

View File

@@ -457,6 +457,8 @@ func applySubmodule(ctx context.Context, plan *InstallPlan, s *InstallStep, inte
if err := os.Rename(dir, target); err != nil {
return fmt.Errorf("build: move checkout to %s: %w", target, err)
}
// From here on a failure must take the checkout away again.
plan.snap.addedCheckout(target)
relTarget, err := filepath.Rel(appDir, target)
if err != nil {
return fmt.Errorf("build: %w", err)