Skip to content

Instantly share code, notes, and snippets.

@ihanson
Created March 22, 2012 07:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ihanson/2156799 to your computer and use it in GitHub Desktop.
Save ihanson/2156799 to your computer and use it in GitHub Desktop.
Attaching a pull request to an existing GitHub issue
#!/usr/bin/env bash
read -p "GitHub username: " -ei $(git config --get github.user) USERNAME
read -sp "GitHub password: " PASSWORD
echo
read -p "Submit pull request to user: " TO_USER
read -p "Submit pull request to repository: " TO_REPO
read -p "Submit pull request to branch: " -ei master TO_BRANCH
read -p "Submit pull request from user: " -ei $USERNAME FROM_USER
read -p "Submit pull request from branch: " FROM_BRANCH
read -p "Issue number to attach pull request to: " ISSUE
read -p "Submit pull request? (y/n) "
if [[ $REPLY =~ ^[Yy] ]]; then
curl -X POST -u "$USERNAME:$PASSWORD" "https://api.github.com/repos/$TO_USER/$TO_REPO/pulls" \
-d "{\"issue\":\"$ISSUE\",\"head\":\"$FROM_USER:$FROM_BRANCH\",\"base\":\"$TO_BRANCH\"}";
fi
@jasongrout
Copy link

Thanks for providing this! Just a guess, but should curl use --data-urlencode instead of -d just in case something needs to be encoded? Or should the content-type be json: -H "Content-Type: application/json" -H "Accept: application/json"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment