shoestrap/assets/default/bin/ghpr

37 lines
794 B
Plaintext
Raw Permalink Normal View History

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