unjs / giget

✨ Download templates and git repositories with pleasure!
MIT License
463 stars 38 forks source link

fix(github): use `api.github.com` for private repository support #93

Closed ishanjain28 closed 1 year ago

ishanjain28 commented 1 year ago

Hey,

So far this project uses the url

https://github.com/<owner>/<repo>/archive/<ref>.tar.gz

This url does not work for private repositories since Github returns 404 response.

I have changed this url to,

https://api.github.com/repos/<owner>/<repo>/tarball/<ref>

This url can be used for public repositories(without a token) and private repositories with a token and it receives a tarball in response same as before.

pi0 commented 1 year ago

Thanks for your pull request and sorry took longer than expected to review.

It is strange because "archives" API was supported previously. It seems a silent breaking change on the GitHub side.

I have made a few changes to comply with github API docs (using Bearer) also URL normalization (also verified locally)

My guess is that this is probably going to break GitHub enterprise users (if any) and there are no clear docs about custom domain examples. Added a TODO comment to try a free trial and verify but I guess public GitHub fix is worth moving this forward earlier 👍🏼

codecov[bot] commented 1 year ago

Codecov Report

Merging #93 (3b5f380) into main (9704865) will increase coverage by 0.98%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #93      +/-   ##
==========================================
+ Coverage   71.06%   72.04%   +0.98%     
==========================================
  Files           6        6              
  Lines         432      440       +8     
  Branches       41       43       +2     
==========================================
+ Hits          307      317      +10     
+ Misses        125      123       -2     
Files Coverage Δ
src/providers.ts 51.31% <100.00%> (+5.72%) :arrow_up:

... and 1 file with indirect coverage changes