shoestrap/assets/default/bin/ghpr
2024-06-24 11:52:00 -07:00

37 lines
794 B
Bash
Executable File

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