-
-
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 pull requests from the command line | |
| # usage: git req repo username | |
| # put somewhere in your PATH as git-req and make executable | |
| GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
| GITPROJECT=$(grep -A3 'remote "'$1'"' .git/config | grep 'url =' | sed -e 's/.*url = [email protected]:.*[/]\(.*\).git$/\1/') | |
| GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/') | |
| GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/') | |
| GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$2 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/') | |
| if [ $GITPULLREQ != 'OK' ]; then | |
| echo -ne '['$1'] Could not complete pull request.\n' | |
| else | |
| echo -ne '['$1'] Pull request sent to '$2'.\n' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment