zyedidia / eget

Easily install prebuilt binaries from GitHub.
MIT License
866 stars 39 forks source link

feat: add support for assets in private repositories #91

Open hhromic opened 10 months ago

hhromic commented 10 months ago

This PR adds support for downloading assets from private repositories in eget.

I had to do some code improvements to facilitate this feature, which I implemented in separate commits for an easier review:

The main changes to support assets in private repositories are in the third commit:

The key aspect is using url instead of browser_download_url in the assets JSON response from GitHub, which always works for both public and private repositories (when using a GitHub token). However, the asset URL uses asset IDs instead of asset filenames. Therefore, I also introduced an Asset type that contains both, the Name of the asset and the DownloadURL.

Then, the majority of the changes are refactoring functions to use Asset instances instead of a plain string. In this way, all functions remain with access to the actual asset name regardless of the URL and thus private assets work seamlessly.

I tested this with both public and private repository assets, and with and without using a GitHub token. I also ran make test and all the defined tests pass OK.

rinshadka commented 5 months ago

Hi , any update on this feature to be merged soon :)