Skip to content

Conversation

@hhromic
Copy link
Contributor

@hhromic hhromic commented Oct 30, 2023

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:

  • feat: add support for assets in private repositories
    • download assets through the GitHub API instead of browser download links
    • allows to download from private repositories when combined with a GitHub token
    • added new Asset type with the Name (necessary for matching) and DownloadURL of an asset
    • ref: https://docs.github.com/en/rest/releases/assets

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
Copy link

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

hhromic added 3 commits June 30, 2024 11:18
* all binary downloads should use the `application/octet-stream` media type
* all GitHub API calls should use the `application/vnd.github+json` media type
* also refactor `GetRateLimit()` to use `Get()` instead of own HTTP request
* ref: <https://docs.github.com/en/rest/overview/media-types>
* download assets through the GitHub API instead of browser download links
* allows to download from private repositories when combined with a GitHub token
* added new Asset type with the Name (necessary for matching) and DownloadURL of an asset
* ref: <https://docs.github.com/en/rest/releases/assets>
@hhromic hhromic force-pushed the feat-privrepo-support branch from cc80c30 to 156c034 Compare June 30, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants