Skip to content

Commit 54fedaf

Browse files
authored
s/campaign/batch change/ (#489)
* Rename command files. * cmd/src campaigns → batch * Minimal package renames. * schemata changes * non-GraphQL renames * Rename Docker image. * Migrate GraphQL. * update readme * Update canned errors in tests. * changelog * insert pr number here
1 parent 35339a2 commit 54fedaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+646
-461
lines changed

.github/workflows/docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
platforms: arm64
3030

31-
- run: ./docker/campaign-volume-workspace/push.py -d ./docker/campaign-volume-workspace/Dockerfile -i sourcegraph/src-campaign-volume-workspace -p linux/amd64,linux/arm64,linux/386
31+
- run: ./docker/batch-change-volume-workspace/push.py -d ./docker/batch-change-volume-workspace/Dockerfile -i sourcegraph/src-batch-change-volume-workspace -p linux/amd64,linux/arm64,linux/386
3232
env:
3333
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
3434
DOCKER_USERNAME: sourcegraphci
@@ -38,5 +38,5 @@ jobs:
3838
with:
3939
username: sourcegraphci
4040
password: ${{ secrets.DOCKER_PASSWORD }}
41-
repository: sourcegraph/src-campaign-volume-workspace
42-
readme-filepath: ./docker/campaign-volume-workspace/README.md
41+
repository: sourcegraph/src-batch-change-volume-workspace
42+
readme-filepath: ./docker/batch-change-volume-workspace/README.md

CHANGELOG.md

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

1616
### Changed
1717

18+
- Campaigns are now known as Batch Changes! The `src campaign` set of commands have been renamed to `src batch`; however, `src campaign` and `src campaigns` will be retained as aliases for `src batch` until the next major version of Sourcegraph. There should be no breaking changes as a result of this change. [#489](https://github.com/sourcegraph/src-cli/pull/489)
19+
1820
### Fixed
1921

2022
### Removed

DEVELOPMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ and get the normal help output from `src`.
6565

6666
## Dependent Docker images
6767

68-
`src campaign apply` and `src campaign preview` use a Docker image published as `sourcegraph/src-campaign-volume-workspace` for utility purposes when the volume workspace is selected, which is the default on macOS. This [Docker image](./docker/campaign-volume-workspace/Dockerfile) is built by [a Python script](./docker/campaign-volume-workspace/push.py) invoked by the GitHub Action workflow described in [`docker.yml`](.github/workflows/docker.yml).
68+
`src batch apply` and `src batch preview` use a Docker image published as `sourcegraph/src-batch-change-volume-workspace` for utility purposes when the volume workspace is selected, which is the default on macOS. This [Docker image](./docker/batch-change-volume-workspace/Dockerfile) is built by [a Python script](./docker/batch-change-volume-workspace/push.py) invoked by the GitHub Action workflow described in [`docker.yml`](.github/workflows/docker.yml).
6969

7070
To build and develop this locally, you can build and tag the image with:
7171

7272
```sh
73-
docker build -t sourcegraph/src-campaign-volume-workspace - < docker/campaign-volume-workspace/Dockerfile
73+
docker build -t sourcegraph/src-batch-change-volume-workspace - < docker/batch-change-volume-workspace/Dockerfile
7474
```
7575

7676
To remove it and then force the upstream image on Docker Hub to be used again:
7777

7878
```sh
79-
docker rmi sourcegraph/src-campaign-volume-workspace
79+
docker rmi sourcegraph/src-batch-change-volume-workspace
8080
```

README.markdown

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- **Search & get results in your terminal**
88
- **Search & get JSON** for programmatic consumption
99
- Make **GraphQL API requests** with auth easily & get JSON back fast
10-
- Execute **[campaign actions](https://docs.sourcegraph.com/user/campaigns)**
10+
- Execute **[batch changes](https://docs.sourcegraph.com/user/batch-changes)**
1111
- **Manage & administrate** repositories, users, and more
1212
- **Easily convert src-CLI commands to equivalent curl commands**, just add --get-curl!
1313

@@ -103,9 +103,8 @@ Is your Sourcegraph instance behind a custom auth proxy? See [auth proxy configu
103103

104104
- `src login` - authenticate to a Sourcegraph instance with your user credentials
105105
- `src search` - perform searches and get results in your terminal or as JSON
106-
- `src actions` - run [campaign actions](https://docs.sourcegraph.com/user/campaigns/actions) to generate patch sets
107106
- `src api` - run Sourcegraph GraphQL API requests
108-
- `src campaigns` - manages [campaigns](https://docs.sourcegraph.com/user/campaigns)
107+
- `src batch` - execute and manage [batch changes](https://docs.sourcegraph.com/user/batch-changes)
109108
- `src repos` - manage repositories
110109
- `src users` - manage users
111110
- `src orgs` - manages organization

cmd/src/batch.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
)
7+
8+
var batchCommands commander
9+
10+
func init() {
11+
usage := `'src batch' manages batch changes on a Sourcegraph instance.
12+
13+
Usage:
14+
15+
src batch command [command options]
16+
17+
The commands are:
18+
19+
apply applies a batch spec to create or update a batch
20+
change
21+
new creates a new batch spec YAML file
22+
preview creates a batch spec to be previewed or applied
23+
repos,repositories queries the exact repositories that a batch spec will
24+
apply to
25+
validate validates a batch spec
26+
27+
Use "src batch [command] -h" for more information about a command.
28+
29+
`
30+
31+
flagSet := flag.NewFlagSet("batch", flag.ExitOnError)
32+
handler := func(args []string) error {
33+
batchCommands.run(flagSet, "src batch", usage, args)
34+
return nil
35+
}
36+
37+
// Register the command.
38+
commands = append(commands, &command{
39+
flagSet: flagSet,
40+
aliases: []string{
41+
"batchchange",
42+
"batch-change",
43+
"batchchanges",
44+
"batch-changes",
45+
"batches",
46+
"campaign",
47+
"campaigns",
48+
},
49+
handler: handler,
50+
usageFunc: func() { fmt.Println(usage) },
51+
})
52+
}

cmd/src/campaigns_apply.go renamed to cmd/src/batch_apply.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,49 @@ import (
66
"flag"
77
"fmt"
88

9-
"github.com/sourcegraph/src-cli/internal/campaigns"
9+
"github.com/sourcegraph/src-cli/internal/batches"
1010
"github.com/sourcegraph/src-cli/internal/output"
1111
)
1212

1313
func init() {
1414
usage := `
15-
'src campaigns apply' is used to apply a campaign spec on a Sourcegraph
16-
instance, creating or updating the described campaign if necessary.
15+
'src batch apply' is used to apply a batch spec on a Sourcegraph instance,
16+
creating or updating the described batch change if necessary.
1717
1818
Usage:
1919
20-
src campaigns apply -f FILE [command options]
20+
src batch apply -f FILE [command options]
2121
2222
Examples:
2323
24-
$ src campaigns apply -f campaign.spec.yaml
24+
$ src batch apply -f batch.spec.yaml
2525
26-
$ src campaigns apply -f campaign.spec.yaml -namespace myorg
26+
$ src batch apply -f batch.spec.yaml -namespace myorg
2727
2828
`
2929

3030
flagSet := flag.NewFlagSet("apply", flag.ExitOnError)
31-
flags := newCampaignsApplyFlags(flagSet, campaignsDefaultCacheDir(), campaignsDefaultTempDirPrefix())
31+
flags := newBatchApplyFlags(flagSet, batchDefaultCacheDir(), batchDefaultTempDirPrefix())
3232

33-
doApply := func(ctx context.Context, out *output.Output, svc *campaigns.Service, flags *campaignsApplyFlags) error {
34-
id, _, err := campaignsExecute(ctx, out, svc, flags)
33+
doApply := func(ctx context.Context, out *output.Output, svc *batches.Service, flags *batchApplyFlags) error {
34+
id, _, err := batchExecute(ctx, out, svc, flags)
3535
if err != nil {
3636
return err
3737
}
3838

39-
pending := campaignsCreatePending(out, "Applying campaign spec")
40-
campaign, err := svc.ApplyCampaign(ctx, id)
39+
pending := batchCreatePending(out, "Applying batch spec")
40+
batch, err := svc.ApplyBatchChange(ctx, id)
4141
if err != nil {
4242
return err
4343
}
44-
campaignsCompletePending(pending, "Applying campaign spec")
44+
batchCompletePending(pending, "Applying batch spec")
4545

4646
out.Write("")
47-
block := out.Block(output.Line(campaignsSuccessEmoji, campaignsSuccessColor, "Campaign applied!"))
47+
block := out.Block(output.Line(batchSuccessEmoji, batchSuccessColor, "Batch change applied!"))
4848
defer block.Close()
4949

50-
block.Write("To view the campaign, go to:")
51-
block.Writef("%s%s", cfg.Endpoint, campaign.URL)
50+
block.Write("To view the batch change, go to:")
51+
block.Writef("%s%s", cfg.Endpoint, batch.URL)
5252

5353
return nil
5454
}
@@ -67,7 +67,7 @@ Examples:
6767
ctx, cancel := contextCancelOnInterrupt(context.Background())
6868
defer cancel()
6969

70-
svc := campaigns.NewService(&campaigns.ServiceOpts{
70+
svc := batches.NewService(&batches.ServiceOpts{
7171
AllowUnsupported: flags.allowUnsupported,
7272
Client: cfg.apiClient(flags.api, flagSet.Output()),
7373
Workspace: flags.workspace,
@@ -86,11 +86,11 @@ Examples:
8686
return nil
8787
}
8888

89-
campaignsCommands = append(campaignsCommands, &command{
89+
batchCommands = append(batchCommands, &command{
9090
flagSet: flagSet,
9191
handler: handler,
9292
usageFunc: func() {
93-
fmt.Fprintf(flag.CommandLine.Output(), "Usage of 'src campaigns %s':\n", flagSet.Name())
93+
fmt.Fprintf(flag.CommandLine.Output(), "Usage of 'src batch %s':\n", flagSet.Name())
9494
flagSet.PrintDefaults()
9595
fmt.Println(usage)
9696
},

0 commit comments

Comments
 (0)