SHARE
TWEET

Untitled

a guest Aug 20th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ \cat ~/.local/bin/git-checkout-pr
  2. #!/bin/bash -e
  3. if [[ $# -ne 1 ]] || [[ ! "$1" =~ (^[1-9][0-9]*$) ]]; then
  4. echo "Usage: $0 <pull request ID>" 1>&2
  5. exit 1
  6. fi
  7.  
  8. ORIGIN='origin'
  9. if git remote | grep -qE '^upstream$'; then
  10. ORIGIN='upstream'
  11. fi
  12.  
  13. PR_ID="$1"
  14. PR_BRANCH="pr-$PR_ID.$(date '+%Y%m%d%H%M%S')"
  15.  
  16. echo "Checking out the pull request $PR_ID from $ORIGIN .."
  17. git fetch "$ORIGIN" "pull/$PR_ID/head:$PR_BRANCH"
  18. git checkout "$PR_BRANCH"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top