mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-01-16 12:18:41 +01:00
32 lines
747 B
Bash
Executable File
32 lines
747 B
Bash
Executable File
#!/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 <username> <branch>"
|
|
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 <username> <branch>"
|
|
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
|