#!/usr/bin/env bash
set -euo pipefail
REV="$1"
shift
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
. "$DIR/scripts/common-setup.sh"
CLEAN=$(mktemp -d 2>/dev/null || mktemp -d -t 'clean') # This crazy workaround ensures that it will work on both Mac OS and Linux; see https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
trap "rm -rf \"$CLEAN\"" EXIT
git clone -n "$DIR" "$CLEAN"
git -C "$CLEAN" checkout "$REV"
cd $CLEAN
$@