diff --git a/misc/checkout-pr.sh b/misc/checkout-pr.sh new file mode 100755 index 000000000..f2796c43f --- /dev/null +++ b/misc/checkout-pr.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ $# -ne "1" ]; then + echo "usage: $0 " + exit 1 +fi + +if [ ! -x "$(command -v curl)" ]; then + echo "You need curl to run this script." + exit 1 +fi + +pr=$1 +pr_json="pr.json" + +curl -o $pr_json https://api.github.com/repos/namhyung/uftrace/pulls/$pr +repo=$(jq -r '.head.repo.html_url' $pr_json) +refspec=$(jq -r '.head.ref' $pr_json) +git fetch $repo $refspec && git checkout -B pull/$pr FETCH_HEAD +exit 0