Skip to content

Instantly share code, notes, and snippets.

@jsocol
Forked from endtwist/git-req
Created June 25, 2010 02:16
Show Gist options
  • Select an option

  • Save jsocol/452299 to your computer and use it in GitHub Desktop.

Select an option

Save jsocol/452299 to your computer and use it in GitHub Desktop.
git-req
#!/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