Skip to content

pre push hook

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy