Skip to content

Commit

Permalink
chore: add script to support testing prs
Browse files Browse the repository at this point in the history
  • Loading branch information
guilatrova committed Oct 30, 2024
1 parent 09c4587 commit 1cfb566
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bin/pull-contributor-pr
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."

0 comments on commit 1cfb566

Please sign in to comment.