When a PR is created in the private repos of my organization, I receive emails from Github with links such as http://github.com/<my org>/<project>/<PR #>.patch
. I would like to download such links with curl; as-is, I get a 404, and I can't seem to find the right incantation with -H "Authorization: <oauth token>"
to make it work.
You can use Github API to do this, get the pull request with this API :
GET /repos/:owner/:repo/pulls/:number
You can use a personal access token with repos
scope to get the result for a private repo with the authorization header : -H 'Authorization: token YOUR_TOKEN'
Use commits comparison and pull request media types :
application/vnd.github.VERSION.patch
application/vnd.github.VERSION.diff
The curl requests are :
request patch for PR #18 :
curl -H 'Authorization: token YOUR_TOKEN' \
-H 'Accept: application/vnd.github.VERSION.patch' \
https://api.github.com/repos/<my org>/<project>/pulls/18
request diff for PR #18
curl -H 'Authorization: token YOUR_TOKEN' \
-H 'Accept: application/vnd.github.VERSION.diff' \
https://api.github.com/repos/<my org>/<project>/pulls/18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With