Skip to content

Commit 648d3df

Browse files
fix(cmd): count queued repos as skipped when rain run aborts
Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
1 parent a26a459 commit 648d3df

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎cmd/rain_parallel_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,18 @@ func TestRunRainReposParallel_PreStartCancelCountsSkipped(t *testing.T) {
164164
t.Fatal("expected skipped progress event for pre-start cancel")
165165
}
166166
}
167+
168+
func TestRunRainReposParallel_AbortCountsQueuedRepos(t *testing.T) {
169+
ctx, cancel := context.WithCancel(context.Background())
170+
cancel()
171+
172+
repos := []git.Repository{
173+
{Name: "a", Path: "/tmp/git-rain-abort-a"},
174+
{Name: "b", Path: "/tmp/git-rain-abort-b"},
175+
{Name: "c", Path: "/tmp/git-rain-abort-c"},
176+
}
177+
totals, _ := runRainReposParallel(&registry.Registry{}, repos, git.RainOptions{RunCtx: ctx}, false, 2, nil, nil, true)
178+
if totals.skipped != 3 {
179+
t.Fatalf("totals.skipped = %d, want 3 (queued repos after abort)", totals.skipped)
180+
}
181+
}

‎cmd/rain_workers.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ func runRainReposParallel(reg *registry.Registry, repos []git.Repository, rainOp
6868
for job := range repoChan {
6969
repo := job.repo
7070
if runCtx != nil && runCtx.Err() != nil {
71+
emitRainEvent(progress, rainexec.Event{
72+
RepoPath: repo.Path,
73+
RepoName: repo.Name,
74+
State: rainexec.StateSkipped,
75+
Detail: "skipped",
76+
})
77+
atomic.AddInt64(&skipped, 1)
7178
continue
7279
}
7380
repoCtx := runCtx

0 commit comments

Comments
 (0)