A simple pre-commit hook for Go developers. Runs gofmt, go vet, and ensures no large files are being added.
Go to file
Laurence Withers a2a9ef0683 Add MIT licence 2020-02-16 09:50:03 +00:00
.gitignore Initial commit with basic tests 2020-02-16 09:48:17 +00:00
LICENSE Add MIT licence 2020-02-16 09:50:03 +00:00
README.md Update README for installation 2020-02-16 09:49:55 +00:00
blacklist.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
check_gofmt.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
check_govet.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
check_largefiles.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
git_stash.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
go.mod Initial commit with basic tests 2020-02-16 09:48:17 +00:00
go.sum Initial commit with basic tests 2020-02-16 09:48:17 +00:00
has_go.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
main.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00
output.go Initial commit with basic tests 2020-02-16 09:48:17 +00:00

README.md

Git pre-commit hook

This commit hook only runs if it detects a Go source repository (by testing for the presence of a go.mod within the first 3 levels of directory).

Tests:

  • runs go vet on each module
  • runs goimports on all source (excluding generating protobuf .pb.go files)
  • checks for large (>1MiB) files

Installation

You can install this commit globally by adding the following to your ~/.gitconfig:

[core]
	hookspath = /home/username/git/hooks

and then copying the executable, named as pre-commit, to the directory you named in hookspath.