Skip to content

Add classified blob reads - #1

Merged
andrew merged 2 commits into
mainfrom
magic-integration
Aug 1, 2026
Merged

Add classified blob reads#1
andrew merged 2 commits into
mainfrom
magic-integration

Conversation

@andrew

@andrew andrew commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Add InspectBlob and BlobResult so callers can retain bounded blob content alongside a magic.Result. Complete reads use Detect, truncated reads use DetectPrefix, and the existing Blob API keeps its NUL-based behavior. Document the new API and cover text, prefix truncation, binary signatures, invalid UTF-8, UTF-16, NUL handling, empty blobs, and input errors.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new blob-reading API that preserves bounded content and returns structured content classification, while keeping the existing Blob NUL-based binary detection semantics intact.

Changes:

  • Introduces InspectBlob and BlobResult for bounded reads with magic.Detect / magic.DetectPrefix classification.
  • Refactors Blob to share a common readBlob helper while preserving its original behavior.
  • Updates package/docs and expands tests/benchmarks to cover classification, truncation, encodings, NUL handling, and error paths.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test_helpers_test.go Generalizes git test helpers to testing.TB so they can be reused from benchmarks.
README.md Documents InspectBlob and clarifies how it differs from the existing Blob behavior.
go.sum Adds checksums for the new github.com/git-pkgs/magic dependency.
go.mod Adds github.com/git-pkgs/magic v0.1.0 as a direct dependency.
doc.go Updates package docstring to reflect blob content classification capability.
blob.go Adds InspectBlob/BlobResult and refactors shared blob read logic into readBlob.
blob_test.go Adds benchmarks and expands tests for InspectBlob classification and error reporting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread blob.go Outdated
@andrew
andrew merged commit 77f574f into main Aug 1, 2026
2 checks passed
@andrew
andrew deleted the magic-integration branch August 1, 2026 11:30
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