Skip to content
Jakob Kogler edited this page Jun 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 of article.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 the e-maxx-eng/.git/hooks/pre-push and give it execution permissions with chmod +x e-maxx-eng/.git/hooks/pre-push.

#!/bin/bash

# Check for .md links
MATCHES=$(grep -E "\[.*\]\(.*\.md(#.*)?\)" src/*/*.md src/index.md)
if [ ! -z "$MATCHES" ];
then
    echo "Links containing .md found:"
    echo "$MATCHES"
    exit 1
fi

# Check for <!--?title TITEL>
MISSING=$(grep -L "<\!--?title" src/*/*.md)
if [ ! -z "$MISSING" ];
then
    echo "Title missing in:"
    echo "$MISSING"
    exit 1
fi

# run tests
cd test
./test.sh
STATUS=$?
if [ $STATUS -ne 0 ];
then
    exit 1
fi

This script will also run automatically at Travis CI whenever somebody pushes to the project or creates a pull request.

Clone this wiki locally