-
-
Save jsocol/452299 to your computer and use it in GitHub Desktop.
git-req
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/bash | |
| # allows you to send pull requests from the command line | |
| # usage: git req username [comparetobranch] | |
| # or: git req username -m [message] | |
| # put somewhere in your PATH as git-req and make executable | |
| GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3) | |
| GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/') | |
| GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/') | |
| GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/') | |
| if [ $(echo "${#2}") != '0' ] | |
| then | |
| if [ "$2" != '-m' ] | |
| then | |
| GITCOMPR="http://github.com/$GITUSER/$GITPROJECT/compare/$2...$GITBRANCH" | |
| else | |
| GITCOMPR=$3 | |
| fi | |
| else | |
| GITCOMPR='' | |
| fi | |
| GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 -Fmessage[body]="$GITCOMPR" "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/') | |
| if [ $GITPULLREQ != 'OK' ] | |
| then | |
| echo -ne 'Could not complete pull request.\n' | |
| else | |
| echo -ne 'Pull request sent to '$1'.\n' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment