Skip to content

Commit

Permalink
feat: add pre-commit hook support
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Jul 17, 2024
1 parent 0650c45 commit df6b998
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
repos:
- repo: https://github.com/ccoVeille/mockery
rev: v2
hooks:
- id: generate-mocks
9 changes: 9 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- id: generate-mocks
name: generate mocks
description: Generate mocks with mockery
language: golang
additional_dependencies:
- github.com/vektra/mockery/v2@latest
entry: mockery
pass_filenames: false
26 changes: 26 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ Generate all the mocks for your project:

docker run -v "$PWD":/src -w /src vektra/mockery --all

### pre-commit

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

```yaml
repos:
- repo: https://github.com/ccoVeille/mockery
rev: v2
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:
```shell
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/)

### Homebrew

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

0 comments on commit df6b998

Please sign in to comment.