#!/bin/bash -xe if [ -z "$GERRIT_NEWREV" ] && [ -z "$GERRIT_REFSPEC" ] then echo "This job may only be triggered by Gerrit." exit 1 fi if [[ ! -e .git ]] then git clone https://review.<%= site %>.org/p/$GERRIT_PROJECT . fi git remote update || git remote update # attempt to work around bug #925790 git reset --hard git clean -x -f -d -q if [ ! -z "$GERRIT_REFSPEC" ] then git checkout $GERRIT_BRANCH git reset --hard remotes/origin/$GERRIT_BRANCH git clean -x -f -d -q git fetch https://review.<%= site %>.org/p/$GERRIT_PROJECT $GERRIT_REFSPEC git merge FETCH_HEAD else git checkout $GERRIT_NEWREV git reset --hard $GERRIT_NEWREV git clean -x -f -d -q fi