#!/bin/bash
if [ "$1" == "--help" ]; then
    printf "Usage: fetch-pull-request [--help] pull_request_id [remote=upstream] \n\n Locally fetch a pull request and test it. \n Remote is set to upstream by default.\n"
    exit 1
elif [ $# -eq 0 ]; then
    echo "Pull request id not given."
    exit 1
else
    set -e -x
    remote=${2:-upstream}
    git fetch $remote pull/$1/head:review-$1
    git checkout review-$1
fi