Skip to content

Commit a1ea085

Browse files
committed
Add scripts to facilitate checkout and merge PR branches for testing purposes
1 parent a8f9528 commit a1ea085

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

remote-branch.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/bash
2+
3+
# if $1 is user:branch, split it into $USER and $BRANCH at the :
4+
if [[ $1 == *:* ]]; then
5+
echo "Splitting $1 into user and branch"
6+
USER=$(echo $1 | cut -d: -f1)
7+
BRANCH=$(echo $1 | cut -d: -f2)
8+
else
9+
# if $1 and $2 are not both specified, fail
10+
if [ -z "$1" ] || [ -z "$2" ]; then
11+
echo "Usage: $0 <username> <branch>"
12+
exit 1
13+
fi
14+
15+
# provide defaults for $1 and $2 for safety anyway
16+
USER=${1:-ripmeapp}
17+
BRANCH=${2:-main}
18+
fi
19+
20+
# Check that USER and BRANCH are not empty
21+
if [ -z "$USER" ] || [ -z "$BRANCH" ]; then
22+
echo "Usage: $0 <username> <branch>"
23+
exit 1
24+
fi
25+
26+
LOCAL_BRANCH=$USER-$BRANCH
27+
REMOTE_BRANCH=$USER/$BRANCH
28+
29+
git remote add $USER https://github.com/$USER/ripme.git
30+
git fetch $USER $BRANCH
31+
git checkout -B $LOCAL_BRANCH $USER/$BRANCH

remote-merge.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/bash
2+
3+
# if $1 is user:branch, split it into $USER and $BRANCH at the :
4+
if [[ $1 == *:* ]]; then
5+
USER=$(echo $1 | cut -d: -f1)
6+
BRANCH=$(echo $1 | cut -d: -f2)
7+
else
8+
# if $1 and $2 are not both specified, fail
9+
if [ -z "$1" ] || [ -z "$2" ]; then
10+
echo "Usage: $0 <username> <branch>"
11+
exit 1
12+
fi
13+
14+
# provide defaults for $1 and $2 for safety anyway
15+
USER=${1:-ripmeapp}
16+
BRANCH=${2:-main}
17+
fi
18+
19+
# Check that USER and BRANCH are not empty
20+
if [ -z "$USER" ] || [ -z "$BRANCH" ]; then
21+
echo "Usage: $0 <username> <branch>"
22+
exit 1
23+
fi
24+
25+
LOCAL_BRANCH=$USER-$BRANCH
26+
REMOTE_BRANCH=$USER/$BRANCH
27+
28+
git remote add $USER https://github.com/$USER/ripme.git
29+
git fetch $USER $BRANCH
30+
git checkout -B $LOCAL_BRANCH origin/main
31+
git merge $REMOTE_BRANCH

0 commit comments

Comments
 (0)