buf icon indicating copy to clipboard operation
buf copied to clipboard

Add --watch flag for generate command to regenerate files on changes

Open fira42073 opened this issue 1 year ago • 4 comments

buf generate --watch is a blocking call that uses https://github.com/fsnotify/fsnotify to watch filesystem changes and regenerate code.

Fix #2418

fira42073 avatar Aug 04 '24 18:08 fira42073

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 04 '24 18:08 CLAassistant

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

fira42073 avatar Aug 04 '24 18:08 fira42073

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

fira42073 avatar Aug 04 '24 18:08 fira42073

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.

bufdev avatar Aug 21 '24 17:08 bufdev