Skip to content
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
5 changes: 3 additions & 2 deletions cmd/src/batch_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ Examples:
ui.ResolvingWorkspaces()
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
var res *service.BatchSpecWorkspaceResolution
for range ticker.C {
res, err := svc.GetBatchSpecWorkspaceResolution(ctx, batchSpecID)
res, err = svc.GetBatchSpecWorkspaceResolution(ctx, batchSpecID)
if err != nil {
return err
}
Expand All @@ -131,7 +132,7 @@ Examples:
break
}
}
ui.ResolvingWorkspacesSuccess()
ui.ResolvingWorkspacesSuccess(res.Workspaces.TotalCount)

// We have to enqueue this for execution with a separate operation.
//
Expand Down
6 changes: 6 additions & 0 deletions internal/batches/service/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ query BatchSpecWorkspaceResolution($batchSpec: ID!) {
workspaceResolution {
failureMessage
state
workspaces {
totalCount
}
}
}
Comment on lines 276 to 282
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs + spaces mixed? 😂

}
Expand All @@ -284,6 +287,9 @@ query BatchSpecWorkspaceResolution($batchSpec: ID!) {
type BatchSpecWorkspaceResolution struct {
FailureMessage string `json:"failureMessage"`
State string `json:"state"`
Workspaces struct {
TotalCount int `json:"totalCount"`
} `json:"workspaces"`
}

func (svc *Service) GetBatchSpecWorkspaceResolution(ctx context.Context, id string) (*BatchSpecWorkspaceResolution, error) {
Expand Down
30 changes: 29 additions & 1 deletion internal/batches/ui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ui
import (
"context"
"fmt"
"math"
"os/exec"

"github.com/neelance/parallel"
Expand Down Expand Up @@ -97,6 +98,7 @@ func (ui *TUI) DeterminingWorkspaceCreatorTypeSuccess(wt workspace.CreatorType)
func (ui *TUI) DeterminingWorkspaces() {
ui.pending = batchCreatePending(ui.Out, "Determining workspaces")
}

func (ui *TUI) DeterminingWorkspacesSuccess(workspacesCount, reposCount int, unsupported batches.UnsupportedRepoSet, ignored batches.IgnoredRepoSet) {
batchCompletePending(ui.pending, fmt.Sprintf("Resolved %d workspaces from %d repositories", workspacesCount, reposCount))

Expand All @@ -113,6 +115,31 @@ func (ui *TUI) DeterminingWorkspacesSuccess(workspacesCount, reposCount int, uns
}
block.Close()
}

ui.maybeWorkspaceCountWarning(workspacesCount, 500)
}

func (ui *TUI) maybeWorkspaceCountWarning(count, limit int) {
if count > limit {
block := ui.Out.Block(output.Linef(
"⚠️", output.StyleWarning,
"Batch changes with more than %d workspaces may be unwieldy to manage.",
limit,
))

for _, line := range []string{
"We're working on providing more filtering options, and you can continue with",
fmt.Sprintf(
"this batch change if you want, but you may want to break it into %d or more",
int(math.Ceil(float64(count)/float64(limit))),
),
"batch changes if you can.",
} {
block.WriteLine(output.Line("", output.StyleSuggestion, line))
}

block.Close()
}
}

func (ui *TUI) CheckingCache() {
Expand Down Expand Up @@ -244,8 +271,9 @@ func (ui *TUI) ResolvingWorkspaces() {
ui.pending = batchCreatePending(ui.Out, "Resolving workspaces")
}

func (ui *TUI) ResolvingWorkspacesSuccess() {
func (ui *TUI) ResolvingWorkspacesSuccess(workspacesCount int) {
batchCompletePending(ui.pending, "Resolving workspaces")
ui.maybeWorkspaceCountWarning(workspacesCount, 2000)
}

func (ui *TUI) ExecutingBatchSpec() {
Expand Down