Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix status bar updates getting lost #389

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to `src-cli` are documented in this file.
### Fixed

- If `src campaign [validate|apply|preview]` was aborted while it was downloading repository archives it could leave behind partial ZIP files that would produce an error on the next run. This is now fixed by deleting partial files on abort. [#388](https://github.com/sourcegraph/src-cli/pull/388)
- A bug in `src campaign [apply|preview]` that would cause status bars in the TUI to not update has been fixed. [#389](https://github.com/sourcegraph/src-cli/pull/389)

### Removed

Expand Down
11 changes: 6 additions & 5 deletions cmd/src/campaign_progress_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ func newCampaignProgressPrinter(out *output.Output, numParallelism int) *campaig
}

type campaignProgressPrinter struct {
out *output.Output
progress output.ProgressWithStatusBars
out *output.Output

progress output.ProgressWithStatusBars
numStatusBars int

maxRepoName int
numParallelism int
Expand Down Expand Up @@ -67,9 +69,8 @@ func (p *campaignProgressPrinter) PrintStatuses(statuses []*campaigns.TaskStatus
return
}

var numStatusBars int
if p.progress == nil {
numStatusBars = p.initProgressBar(statuses)
p.numStatusBars = p.initProgressBar(statuses)
}

newlyCompleted := []*campaigns.TaskStatus{}
Expand Down Expand Up @@ -120,7 +121,7 @@ func (p *campaignProgressPrinter) PrintStatuses(statuses []*campaigns.TaskStatus
_, ok = p.statusBarRepo[statusBarIndex]
}

if statusBarIndex >= numStatusBars {
if statusBarIndex >= p.numStatusBars {
// If the only free slot is past the number of status bars we
// have, there's a race condition going on where we have more tasks
// reporting as "currently executing" than could be executing, most
Expand Down