-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add buf generate --clean flag #3124
Conversation
The latest Buf updates on your PR.
|
extremely drive by comment: wdyt about
my 0.0000002BTC. |
I think I've seen --rm in some other tool, but that could be made up. But I don't know - --clean could infer to me "generate a clean version of the code" or something, whereas --rm is basically saying to me "run the command you'd otherwise have to run manually". But open to more opinions here. |
In my opinion, it would be great to avoid overwriting files that don't change, similar to #3058. For example:
I think it would also be nice to have the flag available in buf.gen.yaml next to out. Then users don't have to specify the flag all the time. And specifying the flag next to the In buf.gen.yaml, Obviously that's much more complex than deleting |
Re:
I think this messaging makes sense to me -- in this case, you are "resetting" the state of your output dir and getting a "clean" version of the output directory. I suppose that is not what you mean by "clean version of the code", but I think given the context of the output directory, clean seems pretty clear to me, although that is definitely subjective. Re: Timo's comment on desired behaviours
This seems good to me, and agree this further supports the name "clean". It would also make the association of "clean" with the output directory much clearer. I think this seems very reasonable to do.
I like this idea, and also like it as a follow-up. I also think it's a little adjacent to this PR, it's addressing a slightly different behaviour/concern and I don't think I would consider that a breaking change/in need of a flag, but I think that is a separate UX and we can probably defer discussing that until we choose to pursue it. |
Overall, I'll update to
This is a much more involved change, however, and |
Of note: I discovered where |
Opened #3126 to track the "smart" version of this. |
As a quick follow-up to #3124 and in response to #3124 (comment), this adds a `clean` config key to `v2` `buf.gen.yaml`, for example: ```yaml version: v2 clean: true plugins: - local: custom-gen-go out: gen/go opt: paths=source_relative strategy: directory - protoc_builtin: java out: gen/java ``` When running `buf generate` with the above configs, the outs set to each plugin (e.g. `gen/go` and `gen/java`) will be removed before code generation is run. If `buf generate --clean` flag is set, then that will always take precedence, even if `clean: false` in the configuration. And likewise, if `buf generate --clean=false`, and `clean: true` in the configuration, then we would not delete the out directories. --------- Co-authored-by: Oliver Sun <[email protected]> Co-authored-by: Oliver Sun <[email protected]> Co-authored-by: bufdev <[email protected]> Co-authored-by: bufdev <[email protected]>
As a quick follow-up to #3124 and in response to #3124 (comment), this adds a `clean` config key to `v2` `buf.gen.yaml`, for example: ```yaml version: v2 clean: true plugins: - local: custom-gen-go out: gen/go opt: paths=source_relative strategy: directory - protoc_builtin: java out: gen/java ``` When running `buf generate` with the above configs, the outs set to each plugin (e.g. `gen/go` and `gen/java`) will be removed before code generation is run. If `buf generate --clean` flag is set, then that will always take precedence, even if `clean: false` in the configuration. And likewise, if `buf generate --clean=false`, and `clean: true` in the configuration, then we would not delete the out directories. --------- Co-authored-by: Oliver Sun <[email protected]> Co-authored-by: Oliver Sun <[email protected]> Co-authored-by: bufdev <[email protected]> Co-authored-by: bufdev <[email protected]>
Fixes #2437.