ichadhr
8/4/2015 - 4:29 PM

Attaching a pull request to an existing GitHub issue

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