-
Notifications
You must be signed in to change notification settings - Fork 412
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
Feature request: pre-commit hooks #791
Comments
Sorry I don't understand the question. Are you asking about git pre-commit hooks? |
I recognize the pattern of https://pre-commit.com So, it's about adding a YAML file to the repository. I don't think there will be a need to maintain the file on version upgrade. Maybe using I can help if you want. I can open a PR. I have already set up such a thing. The only thing I'm worried about is the fact, a pre-commit hooks might generate the mock, but I'm unsure how it could stop the commit. But maybe, I will find it out by testing, or the author of this issue would give us some explanation. Said, otherwise I can help in coding, the need is clear to me as I know pre-commit tool. But I'm unsure what author wants to achieve exactly. Adding the generated mocked file to the commit, prevent the commit when the mocked files are not up to date. Please note for maintainers of the repository, it won't have much consequence than adding a file to the repository, maybe add a section about it in the documentation. Only a few people might use the feature, but it's a convenient way for people to use mockery |
Please note, the work is almost complete with the YAML file provided by @liveFreeOrCode So maybe, he is just asking for a GO to code it by himself. |
Feel free to open a PR. I have never used this tool so I will need education on how this practically speaking will be used by mockery users. I understand the basic concept based on the docs I read of this tool, but perhaps a PR would help solidify the idea for me, in addition to a description of how pre-commit would be configured in a separate repo to pull the YAML config that we will define here. |
I will unless @liveFreeOrCode post a message. @LandonTClipp May I ask you to assign me this issue for now? |
Assigned, thank you! |
👋 Hi @ccoVeille. Thank you for taking this on. I usually drop in a feature request first in issues before I start any work to make sure I work out any gotchas with the maintainers, and to see if it's in line with the product's vision. That said, I probably wasn't going to be able to get to this anytime soon, so I do really appreciate you being able to jump on this.
pre-commit will block a commit if any of the hooks modify a file. So once mockery updates or adds a new mock, the pre-commit output will notify the user that this commit hook modified files, and it will stop the commit so the developer can review the changes that were made by mockery. |
I remembered it was something like that indeed. But I wasn't sure, and was awaiting a feedback from you to know how you were using the local hook you quoted |
PLEASE READ
DO NOT submit tickets without first using the latest version of Golang, clearing your local golang package cache, and re-building mockery using the latest Golang version and the latest version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.
Description
It would be nice to have supported pre-commit hooks capable of generating mocks as part of the normal CD process. Currently I accomplish this as a local hook, but that local hook uses my local golang installation, and if I have a mockery version installed already, the "additional_dependencies" won't be honored.
Mockery Version
latest
Golang Version
go version go1.22.4 linux/amd64
The text was updated successfully, but these errors were encountered: