Skip to content

fix: add support for binary files#20

Closed
marcus-bcl wants to merge 1 commit intodsanders11:mainfrom
marcus-bcl:main
Closed

fix: add support for binary files#20
marcus-bcl wants to merge 1 commit intodsanders11:mainfrom
marcus-bcl:main

Conversation

@marcus-bcl
Copy link
Contributor

This pull requests adds support for files that are not UTF8-encoded - for example JAR files. Previously these would be corrupted on upload.

Inspiration taken from google/go-github#1293 and https://github.com/maticzav/github-tree.

@dsanders11 dsanders11 changed the title Add support for binary files fix: add support for binary files Aug 6, 2024
@dsanders11
Copy link
Owner

Hi @marcus-bcl, thanks for the PR!

I'll try to give this a more thorough review later in the week, but I have some initial questions after a quick glance.

  • "Previously these would be corrupted on upload." - do you have an example of what the corruption looks like? It would be good to extend the integration test to confirm binary files are supported, but the test would need to verify they're not corrupted, so knowing what you were seeing would be helpful.
  • Is detect-character-encoding necessary? Could all blobs simply be created with base64 encoding? If the encoding is just for the API call to GitHub and doesn't affect the final result, I think it would be better to avoid the usage of detect-character-encoding.

@dsanders11
Copy link
Owner

Realized this issue is going to bite my usage as well soon (thanks for pointing it out!), so I made some time to dig into it more. In my testing just base64-encoding all content going to createBlob ends up with the desired result, so detect-character-encoding shouldn't be necessary.

I made a branch with a more concise version of your changes in this PR, with an integration test that I've confirmed fails without the code change and passes with it. Could you verify it works for your use case? Should be able to use it with dsanders11/github-app-commit-action@fix/binary-files.

@marcus-bcl
Copy link
Contributor Author

Realized this issue is going to bite my usage as well soon (thanks for pointing it out!), so I made some time to dig into it more. In my testing just base64-encoding all content going to createBlob ends up with the desired result, so detect-character-encoding shouldn't be necessary.

I made a branch with a more concise version of your changes in this PR, with an integration test that I've confirmed fails without the code change and passes with it. Could you verify it works for your use case? Should be able to use it with dsanders11/github-app-commit-action@fix/binary-files.

That's great, your version looks much simpler. I'll give it a try today and let you know, thank you!

@marcus-bcl
Copy link
Contributor Author

@dsanders11 I've tested from your branch and all looks good.

Here's an example of the JAR file that was uploaded before, which doesn't run and fails checksum validation: gradle/wrapper/gradle-wrapper.jar

And here's the JAR file that was uploaded using your branch, which works as expected: gradle/wrapper/gradle-wrapper.jar

Thanks again!

@dsanders11
Copy link
Owner

Merged that branch and it's released now as v1.4.1, thanks again!

@dsanders11 dsanders11 closed this Aug 7, 2024
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