Skip to content

Commit

Permalink
Merge pull request dnephin#58 from logikone/go-mod-vendor
Browse files Browse the repository at this point in the history
feat: add go-mod-vendor hook
  • Loading branch information
dnephin committed Aug 4, 2020
2 parents 1a6fdf9 + c1665a0 commit 9690bb6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@
files: '\.go$'
language: 'script'
description: "Runs `go mod tidy -v`, requires golang"
- id: go-mod-vendor
name: 'go-mod-vendor'
entry: run-go-mod-vendor.sh
files: '\.go$'
language: 'script'
description: "Runs `go mod vendor`, requires golang"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ Add this to your `.pre-commit-config.yaml`
- `go-unit-tests` - run `go test -tags=unit -timeout 30s -short -v`
- `go-build` - run `go build`, requires golang
- `go-mod-tidy` - run `go mod tidy -v`, requires golang
- `go-mod-vendor` - run `go mod vendor`, requires golang
10 changes: 10 additions & 0 deletions run-go-mod-vendor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

go mod vendor
git diff --exit-code vendor &> /dev/null

if [ $? -eq 1 ]; then
echo "vendor dir differs, please re-add it to your commit"

exit 1
fi

0 comments on commit 9690bb6

Please sign in to comment.