Skip to content

Add buf mod commands to pre-commit hooks#2273

Merged
bufdev merged 2 commits intobufbuild:mainfrom
wittra:ayberkozgur/buf-mod-pre-commit-hook
Jul 11, 2023
Merged

Add buf mod commands to pre-commit hooks#2273
bufdev merged 2 commits intobufbuild:mainfrom
wittra:ayberkozgur/buf-mod-pre-commit-hook

Conversation

@ayberkozgur
Copy link
Contributor

The motivation is to be able to use buf mod update and buf mod prune as 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.

@CLAassistant
Copy link

CLAassistant commented Jul 10, 2023

CLA assistant check
All committers have signed the CLA.

name: buf mod
language: golang
entry: buf mod
files: '(buf\.lock|buf\.yaml)'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be for changes to buf.lock? I think it should just be for buf.yaml but I could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ayberkozgur ayberkozgur requested a review from bufdev July 10, 2023 13:58
- id: buf-mod
name: buf mod
language: golang
entry: buf mod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ayberkozgur ayberkozgur requested a review from bufdev July 10, 2023 14:32
@bufdev
Copy link
Member

bufdev commented Jul 10, 2023

Will look again when comment about splitting commands is addressed, thanks

@ayberkozgur
Copy link
Contributor Author

Will look again when comment about splitting commands is addressed, thanks

@bufdev Done!

@bufdev bufdev changed the title Add buf mod to pre-commit-hooks Add buf mod commands to pre-commit hooks Jul 11, 2023
@bufdev bufdev merged commit db9b1fd into bufbuild:main Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants