Skip to content
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

feat: add pre-commit hook support #795

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- id: generate-mocks
name: generate mocks
description: Generate mocks with mockery
language: golang
entry: go run .
types: [go]
pass_filenames: false

- id: generate-mocks-local
name: generate mocks with local mockery
description: Generate mocks with local mockery
language: system
entry: mockery
types: [go]
pass_filenames: false
41 changes: 39 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,45 @@ Generate all the mocks for your project:

Install through [brew](https://brew.sh/)

brew install mockery
brew upgrade mockery
```shell
brew install mockery
```

Upgrade to the latest version

```shell
brew upgrade mockery
```

### pre-commit

Add the following lines to your `.pre-commit-config.yaml` file

```yaml
repos:
- repo: https://github.com/vektra/mockery
rev: v2 # This is a mutable reference to the latest version
hooks:
- id: generate-mocks
```

!!! note

If the file is missing, you can simply create it with this content

Then install the hook with the following command:

```console
# This one will report a warning about mutable reference
$ pre-commit install

# This one will fix the warning
$ pre-commit autoupdate
```

It will install everything. And from now, your commit will trigger mock generation.

More information about pre-commit can be found on [pre-commit.com/](https://pre-commit.com/)


<script type="text/javascript">
Expand Down
Loading