Skip to content

Commit af88b4c

Browse files
authored
Show warning if 0 changeset specs have been created (#342)
* Show warning if 0 changeset specs have been created * Red exclamation point instead of warning sign
1 parent 8acf623 commit af88b4c

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to `src-cli` are documented in this file.
2222
- The default behaviour of `src campaigns [preview|apply]` has been changed to retain downloaded archives of repositories for better performance across re-runs of the command. To use the old behaviour and delete the archives use the `-clean-archives` flag. Repository archives are also not stored in the directory for temp data (see `-tmp` flag) anymore but in the cache directory, which can be configured with the `-cache` flag. To manually delete archives between runs, delete the `*.zip` files in the `-cache` directory (see `src campaigns -help` for its default location).
2323
- `src campaign [preview|apply]` now check whether `git` and `docker` are available before trying to execute a campaign spec's steps. [#326](https://github.com/sourcegraph/src-cli/pull/326)
2424
- The progress bar displayed by `src campaign [preview|apply]` has been extended by status bars that show which steps are currently being executed for each repository. [#338](https://github.com/sourcegraph/src-cli/pull/338)
25+
- `src campaign [preview|apply]` now shows a warning when no changeset specs have been created.
2526

2627
### Fixed
2728

cmd/src/campaigns_common.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,27 @@ func campaignsExecute(ctx context.Context, out *output.Output, svc *campaigns.Se
258258
}()
259259
}
260260

261-
progress := out.Progress([]output.ProgressBar{
262-
{Label: "Sending changeset specs", Max: float64(len(specs))},
263-
}, nil)
264261
ids := make([]campaigns.ChangesetSpecID, len(specs))
265-
for i, spec := range specs {
266-
id, err := svc.CreateChangesetSpec(ctx, spec)
267-
if err != nil {
268-
return "", "", err
262+
263+
if len(specs) > 0 {
264+
progress := out.Progress([]output.ProgressBar{
265+
{Label: "Sending changeset specs", Max: float64(len(specs))},
266+
}, nil)
267+
for i, spec := range specs {
268+
id, err := svc.CreateChangesetSpec(ctx, spec)
269+
if err != nil {
270+
return "", "", err
271+
}
272+
ids[i] = id
273+
progress.SetValue(0, float64(i+1))
274+
}
275+
progress.Complete()
276+
277+
} else {
278+
if len(repos) == 0 {
279+
out.WriteLine(output.Linef(output.EmojiWarning, output.StyleWarning, `No changeset specs created`))
269280
}
270-
ids[i] = id
271-
progress.SetValue(0, float64(i+1))
272281
}
273-
progress.Complete()
274282

275283
pending = campaignsCreatePending(out, "Creating campaign spec on Sourcegraph")
276284
id, url, err := svc.CreateCampaignSpec(ctx, namespace, rawSpec, ids)

internal/output/emoji.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ package output
33
// Standard emoji for use in output.
44
const (
55
EmojiFailure = "❌"
6+
EmojiWarning = "❗️"
67
EmojiSuccess = "✅"
78
)

0 commit comments

Comments
 (0)