Skip to content

Commit f02a713

Browse files
authored
Don't keep unsupported/ignored repos error for server-side resolution (#804)
The error was the global error and wasn't unset ever, so the execution would go on and eventually it fails with that error in the end. Also fixes a swallowed error for clear cache.
1 parent 8db7dd7 commit f02a713

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ All notable changes to `src-cli` are documented in this file.
1919

2020
### Removed
2121

22+
## 3.42.2
23+
24+
### Fixed
25+
26+
- Fixed an issue where execution would eventually fail with an error when there were unsupported or ignored workspaces found by server-side execution.
27+
2228
## 3.42.1
2329

2430
### Fixed

cmd/src/batch_common.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ func executeBatchSpec(ctx context.Context, ui ui.ExecUI, opts executeBatchSpecOp
354354
)
355355
if svc.Features().ServerSideWorkspaceResolution {
356356
ui.ResolvingRepositories()
357+
var err error
357358
workspaces, repos, err = svc.ResolveWorkspacesForBatchSpec(ctx, batchSpec, opts.flags.allowUnsupported, opts.flags.allowIgnored)
358359
if err != nil {
359360
if repoSet, ok := err.(batches.UnsupportedRepoSet); ok {
@@ -417,7 +418,6 @@ func executeBatchSpec(ctx context.Context, ui ui.ExecUI, opts executeBatchSpecOp
417418

418419
ui.CheckingCache()
419420
tasks := svc.BuildTasks(
420-
ctx,
421421
&template.BatchChangeAttributes{
422422
Name: batchSpec.Name,
423423
Description: batchSpec.Description,
@@ -430,7 +430,9 @@ func executeBatchSpec(ctx context.Context, ui ui.ExecUI, opts executeBatchSpecOp
430430
uncachedTasks []*executor.Task
431431
)
432432
if opts.flags.clearCache {
433-
coord.ClearCache(ctx, tasks)
433+
if err := coord.ClearCache(ctx, tasks); err != nil {
434+
return err
435+
}
434436
uncachedTasks = tasks
435437
} else {
436438
// Check the cache for completely cached executions.

internal/batches/service/build_tasks.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package service
22

33
import (
4-
"context"
5-
64
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
75
"github.com/sourcegraph/sourcegraph/lib/batches/template"
86

97
"github.com/sourcegraph/src-cli/internal/batches/executor"
108
)
119

1210
// buildTasks returns *executor.Tasks for all the workspaces determined for the given spec.
13-
func buildTasks(ctx context.Context, attributes *template.BatchChangeAttributes, steps []batcheslib.Step, workspaces []RepoWorkspace) []*executor.Task {
11+
func buildTasks(attributes *template.BatchChangeAttributes, steps []batcheslib.Step, workspaces []RepoWorkspace) []*executor.Task {
1412
tasks := make([]*executor.Task, 0, len(workspaces))
1513

1614
for _, ws := range workspaces {

internal/batches/service/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ func (svc *Service) DetermineWorkspaces(ctx context.Context, repos []*graphql.Re
368368
return findWorkspaces(ctx, spec, svc, repos)
369369
}
370370

371-
func (svc *Service) BuildTasks(ctx context.Context, attributes *templatelib.BatchChangeAttributes, steps []batcheslib.Step, workspaces []RepoWorkspace) []*executor.Task {
372-
return buildTasks(ctx, attributes, steps, workspaces)
371+
func (svc *Service) BuildTasks(attributes *templatelib.BatchChangeAttributes, steps []batcheslib.Step, workspaces []RepoWorkspace) []*executor.Task {
372+
return buildTasks(attributes, steps, workspaces)
373373
}
374374

375375
func (svc *Service) Features() batches.FeatureFlags {

internal/batches/service/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func mockGraphQLClient(responses ...string) (client api.Client, done func()) {
134134
mux := http.NewServeMux()
135135

136136
var count int
137-
mux.HandleFunc("/.api/graphql", func(w http.ResponseWriter, r *http.Request) {
137+
mux.HandleFunc("/.api/graphql", func(w http.ResponseWriter, _ *http.Request) {
138138
w.Header().Set("Content-Type", "application/json")
139139

140140
_, _ = w.Write([]byte(responses[count]))

0 commit comments

Comments
 (0)