Skip to content

Commit

Permalink
Handle missing flags and correctly allow files in repos and validate …
Browse files Browse the repository at this point in the history
…commands (#675)
  • Loading branch information
eseliger authored Jan 11, 2022
1 parent 964ebf1 commit 090bba6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ All notable changes to `src-cli` are documented in this file.

### Removed

## 3.35.2

### Fixed

- `src batch validate` and `src batch repos` now accept `-allow-unsupported` and `-force-override-ignore` and don't fail on specs using `files` anymore.

## 3.35.1

### Changed
Expand Down
20 changes: 19 additions & 1 deletion cmd/src/batch_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ Examples:
apiFlags = api.NewFlags(flagSet)
)

var (
allowUnsupported bool
allowIgnored bool
)
flagSet.BoolVar(
&allowUnsupported, "allow-unsupported", false,
"Allow unsupported code hosts.",
)
flagSet.BoolVar(
&allowIgnored, "force-override-ignore", false,
"Do not ignore repositories that have a .batchignore file.",
)

handler := func(args []string) error {
if err := flagSet.Parse(args); err != nil {
return err
Expand All @@ -44,7 +57,12 @@ Examples:
ctx := context.Background()
client := cfg.apiClient(apiFlags, flagSet.Output())

svc := service.New(&service.Opts{Client: client})
svc := service.New(&service.Opts{
Client: client,
AllowUnsupported: allowUnsupported,
AllowIgnored: allowIgnored,
AllowFiles: true,
})

if err := svc.DetermineFeatureFlags(ctx); err != nil {
return err
Expand Down
19 changes: 18 additions & 1 deletion cmd/src/batch_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/sourcegraph/sourcegraph/lib/output"

"github.com/sourcegraph/src-cli/internal/api"
"github.com/sourcegraph/src-cli/internal/batches/service"
"github.com/sourcegraph/src-cli/internal/batches/ui"
Expand All @@ -30,6 +31,19 @@ Examples:
apiFlags := api.NewFlags(flagSet)
fileFlag := flagSet.String("f", "", "The batch spec file to read.")

var (
allowUnsupported bool
allowIgnored bool
)
flagSet.BoolVar(
&allowUnsupported, "allow-unsupported", false,
"Allow unsupported code hosts.",
)
flagSet.BoolVar(
&allowIgnored, "force-override-ignore", false,
"Do not ignore repositories that have a .batchignore file.",
)

handler := func(args []string) error {
ctx := context.Background()

Expand All @@ -44,7 +58,10 @@ Examples:
out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})
ui := &ui.TUI{Out: out}
svc := service.New(&service.Opts{
Client: cfg.apiClient(apiFlags, flagSet.Output()),
Client: cfg.apiClient(apiFlags, flagSet.Output()),
AllowUnsupported: allowUnsupported,
AllowIgnored: allowIgnored,
AllowFiles: true,
})

if err := svc.DetermineFeatureFlags(ctx); err != nil {
Expand Down

0 comments on commit 090bba6

Please sign in to comment.