Created
March 14, 2014 22:26
-
-
Save mmassaki/9558284 to your computer and use it in GitHub Desktop.
New pull request from command line
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
| #!/bin/sh | |
| # Author: Massaki | |
| # based on http://www.devthought.com/code/create-a-github-pull-request-from-the-terminal/ | |
| usage () { | |
| echo "usage:" $@ | |
| exit 127 | |
| } | |
| die () { | |
| echo $@ | |
| exit 128 | |
| } | |
| if test $# -lt 2 | |
| then | |
| usage "$0 <remote> <parent branch>" | |
| fi | |
| remote=$1 | |
| parent=$2 | |
| repo=`git remote -v | grep "$remote.*(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"` | |
| if test ${#repo} -le 0 | |
| then | |
| die "Remote repository \"$remote\" not found or invalid. Is it a Github repository?" | |
| fi | |
| branch=`git name-rev --name-only HEAD` | |
| echo "Creating pull request for branch \"$branch\" to branch \"$parent\" in \"$repo\"" | |
| open https://github.com/$repo/pull/new/$parent...$branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment