Skip to content

Commit b209725

Browse files
authored
Merge pull request #54 from alexandregv/feat/add-precommit
Add pre-commit support
2 parents 5f8362c + c917786 commit b209725

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- id: go-arch-lint-check
2+
name: Check Go repo architecture
3+
description: Check Go repo architecture using go-arch-lint
4+
entry: go-arch-lint check
5+
language: golang
6+
pass_filenames: false
7+
8+
- id: go-arch-lint-graph
9+
name: Generate graph for Go repo architecture
10+
description: Generate graph for Go repo architecture using go-arch-lint
11+
entry: go-arch-lint graph
12+
language: golang
13+
pass_filenames: false

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,27 @@ go-arch-lint graph
162162
```
163163

164164
See full [graph documentation](docs/graph/README.md) for details.
165+
166+
### Pre-Commit
167+
168+
go-arch-lint can also be used as a pre-commit hook, acting before each commit is made.
169+
This is useful to always check that your new code still respects your repo architecture, and to always update your graph SVG.
170+
171+
1. Install pre-commit from [https://pre-commit.com/#install](https://pre-commit.com/#install)
172+
2. Create a `.pre-commit-config.yaml` file at the root of your repository with the following content:
173+
174+
```go
175+
repos:
176+
- repo: https://github.com/fe3dback/go-arch-lint
177+
rev: master
178+
hooks:
179+
- id: go-arch-lint-check
180+
- id: go-arch-lint-graph
181+
args: ['--include-vendors=true', '--out=go-arch-lint-graph.svg']
182+
```
183+
184+
3. If needed, add any flags you need in `args`.
185+
4. Auto-update the config to the latest repos' versions by executing `pre-commit autoupdate`
186+
5. Install with `pre-commit install`
187+
6. Now you're all set! Try a commit, and see the logs (passing or failing).
188+

0 commit comments

Comments
 (0)