Skip to content

Instantly share code, notes, and snippets.

@kkaefer
Created September 22, 2011 10:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkaefer/1234462 to your computer and use it in GitHub Desktop.
Save kkaefer/1234462 to your computer and use it in GitHub Desktop.
Converts an issue into a pull request. Works within one repository only and always pulls a branch into master. Requires github.user and github.token to be set.
#!/bin/sh
BRANCH_NAME=$(git symbolic-ref -q HEAD)
BRANCH_NAME=${BRANCH_NAME##refs/heads/}
BRANCH_NAME=${BRANCH_NAME:-HEAD}
REPO_NAME=`git config --get-regexp remote\..+\.url | perl -p -e 's/^remote\.\w+\.url\s+git\@github.com:(.+).git/\$1/'`
echo "Pulling $BRANCH_NAME into master of $REPO_NAME"
read -p "Issue #: " GITHUB_ISSUE
curl -d "pull[base]=master" -d "pull[head]=$BRANCH_NAME" \
-d "pull[issue]=$GITHUB_ISSUE" \
-u "`git config --get github.user`/token:`git config --get github.token`" \
"https://github.com/api/v2/json/pulls/$REPO_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment