Skip to content

Commit 7ee2619

Browse files
authored
batches: fix feature detection in src batch validate (#577)
When creating the `Service` instance, `src batch validate` failed to request or initialise the Sourcegraph feature flags based on the Sourcegraph version in use. As a result, only baseline features were enabled when parsing and validating batch specs. Fixes #576.
1 parent 9ee29f0 commit 7ee2619

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ All notable changes to `src-cli` are documented in this file.
1313

1414
### Added
1515

16+
- `src batch validate` now accepts the standard flags used to control communication with Sourcegraph: `-dump-requests`, `-get-curl`, `-insecure-skip-verify`, and `-trace`. [#577](https://github.com/sourcegraph/src-cli/pull/577)
17+
1618
### Changed
1719

1820
### Fixed
1921

22+
- `src batch validate` would fail to validate batch specs that use features that depend on specific versions of Sourcegraph, such as workspaces. This has been fixed. [#576](https://github.com/sourcegraph/src-cli/issues/576)
23+
2024
### Removed
2125

2226
## 3.30.4

cmd/src/batch_validate.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package main
22

33
import (
4+
"context"
45
"flag"
56
"fmt"
67

78
"github.com/sourcegraph/sourcegraph/lib/output"
9+
"github.com/sourcegraph/src-cli/internal/api"
810
"github.com/sourcegraph/src-cli/internal/batches/service"
911
"github.com/sourcegraph/src-cli/internal/batches/ui"
1012
"github.com/sourcegraph/src-cli/internal/cmderrors"
@@ -25,9 +27,12 @@ Examples:
2527
`
2628

2729
flagSet := flag.NewFlagSet("validate", flag.ExitOnError)
30+
apiFlags := api.NewFlags(flagSet)
2831
fileFlag := flagSet.String("f", "", "The batch spec file to read.")
2932

3033
handler := func(args []string) error {
34+
ctx := context.Background()
35+
3136
if err := flagSet.Parse(args); err != nil {
3237
return err
3338
}
@@ -36,7 +41,13 @@ Examples:
3641
return cmderrors.Usage("additional arguments not allowed")
3742
}
3843

39-
svc := service.New(&service.Opts{})
44+
svc := service.New(&service.Opts{
45+
Client: cfg.apiClient(apiFlags, flagSet.Output()),
46+
})
47+
48+
if err := svc.DetermineFeatureFlags(ctx); err != nil {
49+
return err
50+
}
4051

4152
out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})
4253
if _, _, err := batchParseSpec(fileFlag, svc); err != nil {

0 commit comments

Comments
 (0)