diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1e269e35 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +--- +repos: + - repo: https://github.com/ccoVeille/mockery + rev: v2 + hooks: + - id: generate-mocks \ No newline at end of file diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..3f6667d7 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -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 diff --git a/docs/installation.md b/docs/installation.md index 8dcb10d3..51054ad8 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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/)