Skip to content

Commit bda7607

Browse files
author
Chris Pine
authored
panic if a campaign fetched from the cache has multiple commits (#293)
1 parent 1149bf9 commit bda7607

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

internal/campaigns/executor.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,21 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) {
144144
if result, err = x.cache.Get(ctx, cacheKey); err != nil {
145145
err = errors.Wrapf(err, "checking cache for %q", task.Repository.Name)
146146
return
147-
} else if result != nil && len(result.Commits) == 1 {
147+
}
148+
if result != nil {
148149
// Build a new changeset spec. We don't want to use `result` as is,
149150
// because the changesetTemplate may have changed. In that case
150151
// the diff would still be valid, so we take it from the cache,
151152
// but we still build a new ChangesetSpec from the task.
152-
diff := result.Commits[0].Diff
153+
var diff string
154+
155+
if len(result.Commits) > 1 {
156+
panic("campaigns currently lack support for multiple commits per changeset")
157+
}
158+
if len(result.Commits) == 1 {
159+
diff = result.Commits[0].Diff
160+
}
161+
153162
spec := createChangesetSpec(task, diff)
154163

155164
status.Cached = true

0 commit comments

Comments
 (0)