aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/apply.go
diff options
context:
space:
mode:
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
}