aboutsummaryrefslogtreecommitdiff
path: root/internal/journal/read.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:33:47 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:33:47 +0200
commit2a7452c3fd83000f239755825f38246f8537b6cc (patch)
tree1413ef2f8776927efb7f37b6ba492330920ef3f3 /internal/journal/read.go
parenteb31377e43fb26a6726b741978db83453fcd7bdd (diff)
downloadkrino-2a7452c3fd83000f239755825f38246f8537b6cc.tar.gz
krino-2a7452c3fd83000f239755825f38246f8537b6cc.zip
a permanently deleted file's steps do not keep a run partly undone
Diffstat (limited to 'internal/journal/read.go')
-rw-r--r--internal/journal/read.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/journal/read.go b/internal/journal/read.go
index 438e6ba..5a1de04 100644
--- a/internal/journal/read.go
+++ b/internal/journal/read.go
@@ -230,6 +230,12 @@ func Runs(path string, n int) ([]Run, error) {
order := make([]string, 0)
byID := make(map[string]*Run)
pendingUndo := make(map[string]string) // undo run ID -> the run ID it claims to undo
+ // A file whose chain ended in a permanent delete is never undone, so its
+ // reversible steps do not count toward what a run took (plan 11 review
+ // L8).
+ type fileOf struct{ run, dir, file string }
+ reversibleOf := map[fileOf]int{}
+ deletedFile := map[fileOf]bool{}
for _, line := range lines {
e, ok := parseLine(line)
@@ -247,6 +253,12 @@ func Runs(path string, n int) ([]Run, error) {
}
if e.Status == "ok" {
r.Counts[e.Action]++
+ if _, ok := reversible[e.Action]; ok {
+ reversibleOf[fileOf{e.Run, e.Dir, e.File}]++
+ }
+ if e.Action == "delete" {
+ deletedFile[fileOf{e.Run, e.Dir, e.File}] = true
+ }
}
if e.Action == "run-start" {
if orig, ok := strings.CutPrefix(e.Detail, undoOfPrefix); ok && orig != "" {
@@ -285,8 +297,10 @@ func Runs(path string, n int) ([]Run, error) {
r.UndoOf = pendingUndo[r.ID]
if r.Undone {
took := 0
- for action := range reversible {
- took += r.Counts[action]
+ for f, n := range reversibleOf {
+ if f.run == r.ID && !deletedFile[f] {
+ took += n
+ }
}
r.PartlyUndone = reversed[r.ID] < took
}