32 lines
716 B
Plaintext
Raw Permalink Normal View History

2017-07-11 11:02:31 -07:00
#! /bin/bash
# Created by ViViDboarder. Please share with attribution
2013-08-07 20:23:13 -07:00
# Function used to checkout a pull request into it's own branch
REMOTE=""
PRNUM=""
if [[ "$1" == "" ]]; then
echo "Usage"
echo "ghpr <remote> <pr number>"
echo "Example"
echo "ghpr origin 100"
echo
echo "This function will fetch and clone the pull request as"
echo "a branch."
2017-08-30 16:56:20 -07:00
exit 1
2013-08-07 20:23:13 -07:00
elif [[ "$2" == "" ]]; then
# No remote was supplied
PRNUM="$1"
else
REMOTE="$1"
PRNUM="$2"
fi
echo "git fetch $REMOTE refs/pull/$PRNUM/head:PR_$PRNUM"
git fetch $REMOTE refs/pull/$PRNUM/head:PR_$PRNUM
echo "Just fetched Pull Request #$PRNUM. To switch to this branch execute:"
echo "git checkout PR_$PRNUM"