refactor(devwatch): merge Rebuild and its pass-through rebuild

Rebuild only forwarded to rebuild, and its sole consumer was the
composeService.rebuild forwarder, itself called by a single test. Keep one
exported Rebuild and let that test reach it through the devwatch service.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2026-11-16 15:02:45 +01:00 • committed by Guillaume Lours
parent 1873d72b61
commit 289a6de7bd
3 changed files with 2 additions and 10 deletions

View file

@ -390,7 +390,7 @@ func (s *Service) watchEvents(ctx context.Context, project *types.Project, optio
batchEvents := watch.BatchDebounceEvents(ctx, watcher.Events())
scheduler := newRebuildScheduler(ctx, func(ctx context.Context, services []string) error {
return s.rebuild(ctx, project, services, options)
return s.Rebuild(ctx, project, services, options)
})
// Rebuilds run asynchronously in their own goroutine(s); cancel first so
// an in-flight one can unwind, then wait for it to settle so none
@ -667,10 +667,6 @@ func (s *Service) exec(ctx context.Context, project *types.Project, serviceName
// Rebuild rebuilds the given services and converges what depends on them, as
// the watch loop does when a rebuild trigger fires.
func (s *Service) Rebuild(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error {
return s.rebuild(ctx, project, services, options)
}
func (s *Service) rebuild(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error {
options.LogTo.Log(api.WatchLogger, fmt.Sprintf("Rebuilding service(s) %q after changes were detected...", services))
// Work on a copy so concurrent watch events don't race on the shared
// BuildOptions pointer carried by WatchOptions.

View file

@ -46,10 +46,6 @@ func (s *composeService) watch(ctx context.Context, project *types.Project, opti
return s.devWatch().Watch(ctx, project, options)
}
func (s *composeService) rebuild(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error {
return s.devWatch().Rebuild(ctx, project, services, options)
}
// devWatchBackend is the engine of a composeService, as internal/devwatch sees it.
type devWatchBackend struct {
engineBackend

View file

@ -238,7 +238,7 @@ func TestWatchRebuildTouchesTheRebuiltServiceAndItsDependentsOnly(t *testing.T)
})
options := api.WatchOptions{Build: &api.BuildOptions{}, LogTo: &testLogConsumer{}}
assert.NilError(t, svc.rebuild(t.Context(), project, []string{"app"}, options))
assert.NilError(t, svc.devWatch().Rebuild(t.Context(), project, []string{"app"}, options))
touchesService := func(name, kind string) bool {
for id := range touched {