diff --git a/remote-branch.sh b/remote-branch.sh new file mode 100755 index 00000000..8e26a9d5 --- /dev/null +++ b/remote-branch.sh @@ -0,0 +1,31 @@ +#!/usr/bin/bash + +# if $1 is user:branch, split it into $USER and $BRANCH at the : +if [[ $1 == *:* ]]; then + echo "Splitting $1 into user and branch" + USER=$(echo $1 | cut -d: -f1) + BRANCH=$(echo $1 | cut -d: -f2) +else + # if $1 and $2 are not both specified, fail + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: $0 " + exit 1 + fi + + # provide defaults for $1 and $2 for safety anyway + USER=${1:-ripmeapp} + BRANCH=${2:-main} +fi + +# Check that USER and BRANCH are not empty +if [ -z "$USER" ] || [ -z "$BRANCH" ]; then + echo "Usage: $0 " + exit 1 +fi + +LOCAL_BRANCH=$USER-$BRANCH +REMOTE_BRANCH=$USER/$BRANCH + +git remote add $USER https://github.com/$USER/ripme.git +git fetch $USER $BRANCH +git checkout -B $LOCAL_BRANCH $USER/$BRANCH diff --git a/remote-merge.sh b/remote-merge.sh new file mode 100755 index 00000000..755ccde7 --- /dev/null +++ b/remote-merge.sh @@ -0,0 +1,31 @@ +#!/usr/bin/bash + +# if $1 is user:branch, split it into $USER and $BRANCH at the : +if [[ $1 == *:* ]]; then + USER=$(echo $1 | cut -d: -f1) + BRANCH=$(echo $1 | cut -d: -f2) +else + # if $1 and $2 are not both specified, fail + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: $0 " + exit 1 + fi + + # provide defaults for $1 and $2 for safety anyway + USER=${1:-ripmeapp} + BRANCH=${2:-main} +fi + +# Check that USER and BRANCH are not empty +if [ -z "$USER" ] || [ -z "$BRANCH" ]; then + echo "Usage: $0 " + exit 1 +fi + +LOCAL_BRANCH=$USER-$BRANCH +REMOTE_BRANCH=$USER/$BRANCH + +git remote add $USER https://github.com/$USER/ripme.git +git fetch $USER $BRANCH +git checkout -B $LOCAL_BRANCH origin/main +git merge $REMOTE_BRANCH