Skip to content

Commit 006fb4a

Browse files
committed
fix(cmd): count cancelled repos as skipped in rain summary
Per-repo cancel cleared frozen/failed without ensuring skipped >= 1, so --fetch-mainline cancel outcomes and pre-start worker skips vanished from summary totals while the TUI still showed skipped.
1 parent 3a925f0 commit 006fb4a

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎cmd/rain_outcome.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ func classifyRepoRainOutcome(repoCtx context.Context, delta rainTotals, report j
2525
d := delta
2626
d.frozen = 0
2727
d.failed = 0
28+
// Paths that record cancel as frozen (e.g. --fetch-mainline) leave
29+
// skipped at 0; ensure the repo still appears in the summary.
30+
if d.skipped == 0 {
31+
d.skipped = 1
32+
}
2833
return rainexec.StateSkipped, d
2934
}
3035

‎cmd/rain_outcome_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ func TestClassifyRepoRainOutcome_SkipDoesNotCountFrozen(t *testing.T) {
1717
if delta.frozen != 0 {
1818
t.Fatalf("frozen = %d, want 0", delta.frozen)
1919
}
20+
if delta.skipped != 1 {
21+
t.Fatalf("skipped = %d, want 1", delta.skipped)
22+
}
2023
}
2124

2225
func TestClassifyRepoRainOutcome_SkipAfterWorkShowsDone(t *testing.T) {

‎cmd/rain_parallel_test.go‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ package cmd
22

33
import (
44
"bytes"
5+
"context"
56
"encoding/json"
67
"io"
78
"os"
89
"strings"
910
"testing"
1011
"time"
1112

13+
testutil "github.com/git-fire/git-testkit"
1214
"github.com/git-rain/git-rain/internal/git"
15+
"github.com/git-rain/git-rain/internal/rainexec"
1316
"github.com/git-rain/git-rain/internal/registry"
14-
testutil "github.com/git-fire/git-testkit"
1517
)
1618

1719
func TestRunRainOnRepos_ParallelStallDoesNotBlockHealthy(t *testing.T) {
@@ -135,3 +137,30 @@ func TestRunRainReposParallel_PreservesSelectionIndex(t *testing.T) {
135137
}
136138
}
137139
}
140+
141+
func TestRunRainReposParallel_PreStartCancelCountsSkipped(t *testing.T) {
142+
repos := []git.Repository{{Name: "pending", Path: "/tmp/git-rain-never-started"}}
143+
coord := newRainCoordinator(context.Background(), []string{repos[0].Path})
144+
coord.SkipRepo(repos[0].Path)
145+
146+
progress := make(chan rainexec.Event, 4)
147+
totals, _ := runRainReposParallel(&registry.Registry{}, repos, git.RainOptions{}, false, 1, progress, coord, true)
148+
close(progress)
149+
150+
if totals.skipped != 1 {
151+
t.Fatalf("totals.skipped = %d, want 1 (pre-start cancel must count in summary)", totals.skipped)
152+
}
153+
if totals.updated != 0 || totals.frozen != 0 || totals.failed != 0 {
154+
t.Fatalf("unexpected non-skip totals: %+v", totals)
155+
}
156+
157+
var sawSkipped bool
158+
for e := range progress {
159+
if e.State == rainexec.StateSkipped {
160+
sawSkipped = true
161+
}
162+
}
163+
if !sawSkipped {
164+
t.Fatal("expected skipped progress event for pre-start cancel")
165+
}
166+
}

‎cmd/rain_workers.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func runRainReposParallel(reg *registry.Registry, repos []git.Repository, rainOp
8181
State: rainexec.StateSkipped,
8282
Detail: "skipped",
8383
})
84+
atomic.AddInt64(&skipped, 1)
8485
continue
8586
}
8687

0 commit comments

Comments
 (0)