feat: add support for assets in private repositories #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Bearer
authorization schemeAccept
header inGet()
application/octet-stream
media typeapplication/vnd.github+json
media typeGetRateLimit()
to useGet()
instead of own HTTP requestThe main changes to support assets in private repositories are in the third commit:
The key aspect is using
url
instead ofbrowser_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 anAsset
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 plainstring
. 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.