Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.8k
pre push hook
Jakob Kogler edited this pageJun 1, 2018 ·1 revision
When contributing to the project, I quite frequently made a few errors that should not happen:
- Link to
article.md
pages instead ofarticle.html
. - Forget to add a title.
The following script checks if any of the two errors occurred before push to the server, and stop the process with an error message if the script didn't finish successfully.Additionally it also runs all tests and stops if the push process if a test is not successful.
Just put the following code in thee-maxx-eng/.git/hooks/pre-push
and give it execution permissions withchmod +x e-maxx-eng/.git/hooks/pre-push
.
#!/bin/bash# Check for .md linksMATCHES=$(grep -E "\[.*\]\(.*\.md(#.*)?\)" src/*/*.md src/index.md)if [ ! -z "$MATCHES" ];then echo "Links containing .md found:" echo "$MATCHES" exit 1fi# Check for <!--?title TITEL>MISSING=$(grep -L "<\!--?title" src/*/*.md)if [ ! -z "$MISSING" ];then echo "Title missing in:" echo "$MISSING" exit 1fi# run testscd test./test.shSTATUS=$?if [ $STATUS -ne 0 ];then exit 1fi
This script will also run automatically at Travis CI whenever somebody pushes to the project or creates a pull request.