-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add script to support testing prs
- Loading branch information
1 parent
09c4587
commit 1cfb566
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# Usage: ./pull_pr.sh owner:branch [-r] | ||
|
||
# Set repository name | ||
readonly REPO_NAME="tryceratops" | ||
|
||
# Extract owner and branch from the first argument | ||
IFS=":" read -r OWNER BRANCH <<< "$1" | ||
|
||
# Check if -r flag is passed to remove the remote afterward | ||
REMOVE_REMOTE=false | ||
if [[ "$2" == "-r" ]]; then | ||
REMOVE_REMOTE=true | ||
fi | ||
|
||
# Add the contributor's remote | ||
CONTRIBUTOR_REMOTE="${OWNER}_remote" | ||
git remote add "$CONTRIBUTOR_REMOTE" "https://github.com/$OWNER/$REPO_NAME.git" | ||
|
||
git fetch "$CONTRIBUTOR_REMOTE" "$BRANCH" | ||
git checkout -b "${OWNER}_${BRANCH}" "$CONTRIBUTOR_REMOTE/$BRANCH" | ||
|
||
# Remove the remote if -r flag was provided | ||
if [ "$REMOVE_REMOTE" = true ]; then | ||
git remote remove "$CONTRIBUTOR_REMOTE" | ||
echo "Removed remote $CONTRIBUTOR_REMOTE" | ||
fi | ||
|
||
echo "Branch ${OWNER}_${BRANCH} checked out successfully." |