Fix #5847: Replace shell binary check with Kotlin script and tests#6168
Open
Sandesh282 wants to merge 1 commit intooppia:developfrom
Open
Fix #5847: Replace shell binary check with Kotlin script and tests#6168Sandesh282 wants to merge 1 commit intooppia:developfrom
Sandesh282 wants to merge 1 commit intooppia:developfrom
Conversation
Coverage ReportResultsNumber of files assessed: 1 Passing coverageFiles with passing code coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #5847
Explanation
Fixes #5847: The existing binary file check in
pre-commit.shusesfile --mime | grep binary, which produces false positives on text files like.textproto,.json,.xml, and.md. This PR replaces that unreliable shell-based check with a robust Kotlin script (BinaryFileCheck.kt) that uses a two-layer detection approach:.kt,.java,.xml,.json,.textproto,.proto,.md,.sh,.bazel,.pro, etc.) pass extension validation. Files with unknown extensions are flagged as binary (fail-safe).A filepath-based exemption list (
binary_file_exemptions.textproto) is used to allow legitimate binary files (e.g., PNG images, GPG keys). Stale exemptions (paths that no longer exist) cause the check to fail, keeping the list up to date.Changes to
scripts/assets: Addedbinary_file_exemptions.textprotocontaining the 20 existing legitimate binary files in the repository (PNG images indrawable-nodpi/andmipmap-*/, GPG key files in.gitsecret/, and the encrypted remote cache credentials config).Essential Checklist
For UI-specific PRs only
Not applicable. This PR only modifies scripts, build configs, and CI workflows with no UI changes.