Skip to content

Commit 483cab7

Browse files
authored
Cache results in repository even if diff was empty (#374)
1 parent 91c8421 commit 483cab7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

CHANGELOG.md

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

2020
### Fixed
2121

22+
- `src campaign [apply|preview]` now caches the result of running steps in a repository even if they didn't produce changes.
23+
2224
## 3.21.8
2325

2426
### Fixed

internal/campaigns/executor.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,25 +261,25 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) {
261261
return
262262
}
263263

264+
// Build the changeset spec.
265+
spec := createChangesetSpec(task, string(diff), x.features)
266+
267+
// Add to the cache. We don't use runCtx here because we want to write to
268+
// the cache even if we've now reached the timeout.
269+
if err = x.cache.Set(ctx, cacheKey, spec); err != nil {
270+
err = errors.Wrapf(err, "caching result for %q", task.Repository.Name)
271+
}
272+
264273
// If the steps didn't result in any diff, we don't need to add it to the
265274
// list of specs that are displayed to the user and send to the server.
266275
if len(diff) == 0 {
267276
x.updateTaskStatus(task, status)
268277
return
269278
}
270279

271-
// Build the changeset spec.
272-
spec := createChangesetSpec(task, string(diff), x.features)
273-
274280
status.ChangesetSpec = spec
275281
x.updateTaskStatus(task, status)
276282

277-
// Add to the cache. We don't use runCtx here because we want to write to
278-
// the cache even if we've now reached the timeout.
279-
if err = x.cache.Set(ctx, cacheKey, spec); err != nil {
280-
err = errors.Wrapf(err, "caching result for %q", task.Repository.Name)
281-
}
282-
283283
// Add the spec to the executor's list of completed specs.
284284
x.specsMu.Lock()
285285
x.specs = append(x.specs, spec)

0 commit comments

Comments
 (0)