-
-
Save dblevins/6e255634d84914beb051a4b3858ebfb4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
##----------------------------------------- | |
## | |
## Small script to help make it slightly faster | |
## to apply Github PRs to a local clone. | |
## | |
## Purl is short for PR URL. Usage is simple: | |
## | |
## $ cd tomee-site-generator | |
## $ purl https://github.com/apache/tomee-site-generator/pull/7 | |
## | |
## You must still ensure your local repo is up | |
## to date and ready for work. | |
## | |
## Check for script updates: https://gist.github.com/dblevins/6e255634d84914beb051a4b3858ebfb4 | |
## | |
##----------------------------------------- | |
URL="${1?Specify the Github PR url}" | |
# Grab the user and branch name | |
PR=($(curl -s "$URL" | \ | |
tr '\n' ' ' | \ | |
perl -pe 's,.*<span class="css-truncate-target user">([^>]+)</span>:<span class="css-truncate-target">([^>]+)</span></span>.*,$1 $2,g' | |
)) | |
# Pull the repo name from the remote list | |
REPO=$(git remote -v | grep 'origin.*push' | perl -pe 's,.*[:/]([a-zA-Z0-9-]+).git .push.,$1,') | |
# Now apply the PR | |
echo git pull git@github.com:"${PR[0]}"/"$REPO".git "${PR[1]}" | |
git pull git@github.com:"${PR[0]}"/"$REPO".git "${PR[1]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment