Skip to content

Instantly share code, notes, and snippets.

@clehner
Created January 21, 2016 03:25
Show Gist options
  • Save clehner/5cf0af6d96321a36e94c to your computer and use it in GitHub Desktop.
Save clehner/5cf0af6d96321a36e94c to your computer and use it in GitHub Desktop.
Attach a pull request to an existing issue on GitHub
#!/bin/sh
# http://stackoverflow.com/questions/4528869/how-do-you-attach-a-new-pull-request-to-an-existing-issue-on-github
if [ $# -lt 4 ]; then
echo "Usage: ${0##*/} [issue_num] [username/repo] [base_branch] [head_username:branch]" >&2
exit 1
fi
user="$(pass github.com|awk '/^username:/{print $2}')"
issue=$1
repo=$2
base=$3
head=$4
curl --user "$user" \
--header "X-GitHub-OTP: $(read -p 'Enter OTP: ' otp; echo $otp)" \
-d "{\"issue\": \"$issue\", \"head\": \"$head\", \"base\": \"$base\"}" \
"https://api.github.com/repos/$repo/pulls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment