Created
September 4, 2018 23:18
-
-
Save ScopeyNZ/194c854925ada5e02070c8c9c0561fc4 to your computer and use it in GitHub Desktop.
Attempts to calculate the proper head branch when running `hub pull-request`
This file contains hidden or 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
# Find the right head | |
LOCAL_BRANCH=`git name-rev --name-only HEAD` | |
REMOTE_BRANCH=`git branch -r | grep "$LOCAL_BRANCH"` | |
IFS='/' | |
read -r REMOTE BLAH <<< "$REMOTE_BRANCH" | |
IFS=' ' | |
# Trim the remote name | |
REMOTE=`echo $REMOTE | sed -e 's/^[ \t]*//'` | |
# Get the full-name of the git remote | |
REMOTE_FULLNAME=`git remote -v | grep "^$REMOTE" | head -1 | perl -nle 'm/(git@|https:\/\/)github\.com(:|\/)([^\/]+)\/[^(]+\(fetch\)/; print $3'` | |
HEAD=$REMOTE_FULLNAME:$LOCAL_BRANCH | |
hub pull-request -h $HEAD $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment