Add --watch flag for generate command to regenerate files on changes
buf generate --watch is a blocking call that uses https://github.com/fsnotify/fsnotify to watch filesystem changes and regenerate code.
Fix #2418
I've also bumped up the docker version from v27.0.0 to v27.0.01 to avoid the issue
go: downloading github.com/docker/docker v27.0.0+incompatible
go: github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugindocker imports
github.com/docker/docker/api/types: reading github.com/docker/docker/go.mod at revision v27.0.0: unknown revision v27.0.0
go: github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugindocker imports
github.com/docker/docker/api/types/image: reading github.com/docker/docker/go.mod at revision v27.0.0: unknown revision v27.0.0
go: github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugindocker imports
github.com/docker/docker/client: reading github.com/docker/docker/go.mod at revision v27.0.0: unknown revision v27.0.0
go: github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugindocker imports
github.com/docker/docker/pkg/jsonmessage: reading github.com/docker/docker/go.mod at revision v27.0.0: unknown revision v27.0.0
go: github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugindocker imports
github.com/docker/docker/pkg/stringid: reading github.com/docker/docker/go.mod at revision v27.0.0: unknown revision v27.0.0
More context: https://bufbuild.slack.com/archives/CRZ680FUH/p1722779009632599
Solutions inspired by: https://github.com/air-verse/air/blob/master/runner/util.go#L259 https://github.com/fsnotify/fsnotify/blob/main/cmd/fsnotify/dedup.go
Thanks for the PR. We don't have too much bandwidth to dive into this at the moment, but we'll get back to you. There are some issues with how the watch is handling inputs, and the separation of concerns with the os package, but we unfortunately can't dive into them at the moment.