#! /bin/sh

# this hook prints a message that can be used to start a jenkins job on our CI server
# also prevents repository admins from pushing directly to master by accident

read ref name remote_ref remote_name

if test "$ref" = refs/heads/master; then
    echo do not push directly to master >&2
    echo make a branch and use the bootleg-ci-merge jenkins job >&2
    exit 1
fi

# we could try and figure out which remote branch is the closest
# ancestor to make an educated guess at a default target branch.
# TARGET_BRANCH=$( ?? )
SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
TUTA_JENKINS_BASE_URL="https://next.tutao.de/jenkins/"

echo "use this link to start the job to check your work and merge it into your target branch:"
echo "${TUTA_JENKINS_BASE_URL}job/bootleg-ci-merge/parambuild?SOURCE_BRANCH=${SOURCE_BRANCH}&CLEAN_WORKSPACE=false&DRY_RUN=false"
