github.com/jaylevin/jenkins-library@v1.230.4/.hooks/README.md (about) 1 # Git Hooks 2 3 From [Git docs](https://git-scm.com/docs/githooks#_description): 4 5 > Hooks are programs you can place in a hooks directory to trigger actions at certain points in git’s execution. Hooks that don’t have the executable bit set are ignored. 6 7 ## Usage 8 9 To use the hook, execute this command in the project root directory to link the script into the `.git/hooks` directory: 10 11 ```sh 12 ln -s -f ../../.hooks/pre-commit ./.git/hooks/pre-commit 13 ``` 14 15 Make sure the file is executable: 16 17 ```sh 18 chmod +x ./.hooks/pre-commit 19 ``` 20 21 ## Pre-Commit Hook 22 23 From [Git docs](https://git-scm.com/docs/githooks#_pre_commit): 24 25 > This hook is invoked by git-commit, and can be bypassed with the --no-verify option. It takes no parameters, and is invoked before obtaining the proposed commit log message and making a commit. Exiting with a non-zero status from this script causes the git commit command to abort before creating a commit. 26 27 ### Content 28 29 Executes `go mod tidy` and stages `go.mod` & `go.sum`. 30 31 From [Golang docs](https://github.com/golang/go/wiki/Modules): 32 33 > `go mod tidy` — Prune any no-longer-needed dependencies from `go.mod` and add any dependencies needed for other combinations of OS, architecture, and build tags (details).