Add buf mod commands to pre-commit hooks#2273
Add buf mod commands to pre-commit hooks#2273bufdev merged 2 commits intobufbuild:mainfrom wittra:ayberkozgur/buf-mod-pre-commit-hook
buf mod commands to pre-commit hooks#2273Conversation
| name: buf mod | ||
| language: golang | ||
| entry: buf mod | ||
| files: '(buf\.lock|buf\.yaml)' |
There was a problem hiding this comment.
Why would this be for changes to buf.lock? I think it should just be for buf.yaml but I could be wrong.
There was a problem hiding this comment.
TBH I don't have a 100% accurate feeling on this. On one hand it's not supposed to be touched by devs. On the other hand nothing prevents them from doing so. So in the end I think it's slightly better behavior to listen to changes on the lock as well.
.pre-commit-hooks.yaml
Outdated
| - id: buf-mod | ||
| name: buf mod | ||
| language: golang | ||
| entry: buf mod |
There was a problem hiding this comment.
As opposed to other commands in this list, this is just a partial command - can you explain how this works? Ie all above commands are actual commands that you run, while buf mod is a container for update, etc
There was a problem hiding this comment.
Indeed; I plan that it should work via setting e.g args: [update] or args: [prune]. I think this is better compared to making one pre-commit entry for each subcommand of buf mod.
There was a problem hiding this comment.
For consistency's sake I might argue the opposite - given the number of commands that are relevant to precommit (small), adding two commands instead of one seems appropriate.
There was a problem hiding this comment.
I would argue for the opposite because there are many subcommands to buf mod that will potentially require one entry each there and this would pollute this file. But to me as a user of this repo it makes no difference so I can make the change you want.
|
Will look again when comment about splitting commands is addressed, thanks |
@bufdev Done! |
buf mod to pre-commit-hooksbuf mod commands to pre-commit hooks
The motivation is to be able to use
buf mod updateandbuf mod pruneas a pre-commit hook upon changes in the buf module and lock files. We currently have to do it with a repo local hook with system language.