#!/bin/sh
# This follows the same idea as the `pre-commit' script, but is meant to be run
# after the commit is accepted/completed/finalized.  This would be a good place
# to inform a buildbot to start an automated build, for example.
#
# Modifications:
#   Mark C. Miller, Mon Sep 10 19:04:39 PDT 2012
#   Commented out ciabot hook due to unreliability of connectivity to ciabot
#   server as well as comments in this thread,
#   http://osgeo-org.1560.n6.nabble.com/SVN-Commit-Slowness-td4997449.html
#   indicating its an svn commit peformance issue.

REPOS="$1"
REV="$2"

#
# Set some env variables used by the scripts
#
source ${REPOS}/hooks/hook_common.sh

#
# Check that we have valid input parameters
#
if test -z "${REPOS}"; then
    log "Repository path not set in $0."
    exit 1
fi
if test -z "${REV}"; then
    log "Revision number not set in $0."
    exit 1
fi

function run_sh()
{
   SCRIPT="$@"
   sh ${REPOS}/hooks/${SCRIPT} ${REPOS} ${REV}
   if [ $? != 0 ]; then
       hadError=1
   fi
}

#env -i ${REPOS}/hooks/ciabot_svn.py ${REPOS} ${REV} &

# Tell the VisIt anonymous svn site to sync. (throw the file away)
wget -o /dev/null -O /dev/null --timeout 20 http://50.56.174.237/trigger.php

# handle automatic installation of updated/new hooks. Should probably
# remain first.
run_sh "hooks_update.sh"

# Uncomment if you want to grab the committing user's email.
#email=`sh ${REPOS}/hooks/output_email.sh ${REPOS} ${REV}`

run_sh "state_update.sh"

exit $hadError
