Closed
Description
Is it possible to do all the git options via the GitHub API instead?
- This could also be used to check if an upgrade branch already exists for a package, and get that branch's
package.json
too.Create a new branch off master SHA: https://gist.github.com/potherca/3964930Update a file (i.e. in new branch): https://developer.github.com/v3/repos/contents/#update-a-file
Activity
rarkins commentedon Dec 19, 2016
https://api.github.com/repos/singapore/package-test/contents/package.json seems to return the
package.json
in base64 format, but when I copy/paste the "content" field into online decoders, it seems to have a character problem.The response also includes a "download_url" field which works (gives the raw file).
rarkins commentedon Dec 19, 2016
Adding
Accept: application/vnd.github.VERSION.raw
header gets you the raw file!rarkins commentedon Dec 19, 2016
A URL like https://api.github.com/repos/singapore/package-test/contents/package.json?ref=upgrade/angular will get the package.json from branch "upgrade/angular". If the branch/file doesn't exist then you get a response like:
rarkins commentedon Dec 19, 2016
The master SHA can be found with this URL: https://api.github.com/repos/singapore/package-test/commits/master
rarkins commentedon Dec 19, 2016
Create a branch. Use https://api.github.com/repos/singapore/package-test/git/refs. Response is:
rarkins commentedon Dec 19, 2016
Get the SHA of package.json for branch
testtest1
: https://api.github.com/repos/singapore/package-test/contents/package.json?ref=testtest1rarkins commentedon Dec 19, 2016
Updating package.json in a branch also worked.
URL: https://api.github.com/repos/singapore/package-test/contents/package.json
Body:
Refactor to use GitHub API instead of git