Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  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"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement