aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/apply.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:26:12 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:26:12 +0200
commit3bfafbc8664a2a1ba8efc3f64376ff63c3dc11b9 (patch)
tree1b2de6bd79c7c0225a2f3e4a0fccc51c3cc627ba /internal/engine/apply.go
parent8c6afca96a9f0af41c5a9d05beb7f1dedb994740 (diff)
downloadkrino-3bfafbc8664a2a1ba8efc3f64376ff63c3dc11b9.tar.gz
krino-3bfafbc8664a2a1ba8efc3f64376ff63c3dc11b9.zip
plan 9: apply logs each step as it completes and stops a chain that landed elsewhere
Diffstat (limited to 'internal/engine/apply.go')
-rw-r--r--internal/engine/apply.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/engine/apply.go b/internal/engine/apply.go
index ce05636..83ea4fe 100644
--- a/internal/engine/apply.go
+++ b/internal/engine/apply.go
@@ -110,11 +110,13 @@ func (e *Engine) applyFile(dirName string, c plan.Chain, approved bool, j *journ
return FileResult{File: c.File, Steps: steps}, nil
}
- results := apply.Chain(c)
- for i, sr := range results {
- if err := e.logStep(j, run, dirName, rel, i+1, c.Steps[i], sr); err != nil {
- return FileResult{}, err
- }
+ // Each step is logged the moment it has run (review M9), not after the
+ // whole chain: a run killed mid-chain must leave what it did undoable.
+ results, err := apply.ChainLogged(c, func(i int, sr apply.StepResult) error {
+ return e.logStep(j, run, dirName, rel, i+1, c.Steps[i], sr)
+ })
+ if err != nil {
+ return FileResult{}, err
}
return FileResult{File: c.File, Steps: results}, nil
}