Skip to content

Instantly share code, notes, and snippets.

@ichadhr
Forked from ihanson/attach-pull-request
Last active October 7, 2019 15:51
Show Gist options
  • Save ichadhr/085bf637af9f4f334cd8 to your computer and use it in GitHub Desktop.
Save ichadhr/085bf637af9f4f334cd8 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment