I am trying to write a pre-receive hook
for git that will pull the latest version of the code being pushed and run unit tests against it. My code is below, but when it gets to "git checkout $newrev", I get:
remote: fatal: reference is not a tree: 188de39ca68e238bcd7ee9842a79397f39a5849e
What do I need to do to get a checkout of the code being pushed before the receive has happened?
#!/bin/bash
while read oldrev newrev refname
do
echo "Preparing to run unit tests for $newrev"
TEST_DIR=/opt/git/sommersault-push-tests/sommersault
# check out this version of the code
unset GIT_DIR
echo $refname
cd $TEST_DIR
git checkout $newrev
...do more stuff...
done