Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve binary detection #1043

Merged
merged 1 commit into from Sep 26, 2023
Merged

Conversation

sebastinez
Copy link
Member

@sebastinez sebastinez commented Sep 25, 2023

libgit2 optimizes around not loading the content, when there's no content callbacks configured.

So we aren't able to get a clear answer from radicle-surf if a file in a diff is a binary or not.

A simple way without doing additional API requests is to check if the file type is a executable and if there are no hunks (since we don't get any deltas in binaries), this is a strong
indicator for a binary.

References:
libgit2/libgit2#6637 (comment)
rust-lang/git2-rs#991

Closes #1039

@sebastinez sebastinez self-assigned this Sep 25, 2023
@vercel
Copy link

vercel bot commented Sep 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radicle-interface ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2023 7:04am

@github-actions
Copy link

github-actions bot commented Sep 25, 2023

Visual diff results for latest changes

✅ There are no visual differences between master and this branch.

Copy link
Member

@rudolfs rudolfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a testcase for this?

libgit2 optimizes around not loading the content, when there's no
content callbacks configured.

So we aren't able to get a clear answer from radicle-surf if a file in a
diff is a binary or not.

A simple way without doing additional API requests is to check if the
file type is a executable and if there are no hunks (since we don't get
any deltas in binaries), this is a strong
indicator for a binary.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
Copy link
Member

@rudolfs rudolfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@sebastinez sebastinez merged commit bd6ba78 into master Sep 26, 2023
10 checks passed
@sebastinez sebastinez deleted the sebastinez/improve-binary-detection branch September 26, 2023 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants