-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add docs for blob.jl #22555
Add docs for blob.jl #22555
Changes from 1 commit
87ad13e
4cea271
2d298d3
7ac475f
569cb2f
8d12869
2562bba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,24 @@ function Base.length(blob::GitBlob) | |
return ccall((:git_blob_rawsize, :libgit2), Int64, (Ptr{Void},), blob.ptr) | ||
end | ||
|
||
""" | ||
rawcontent(blob::GitBlob) -> Array | ||
|
||
Fetch the *raw* contents of the [`GitBlob`](@ref) `blob`. This is a read-only | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does read only mean here? you can always write to julia arrays There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did the revised wording make this clearer? |
||
`Array` containing the contents of the blob, which may be binary or may be ASCII | ||
`String` data. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused a bit by this wording. Is it always just raw bytes which may or may not be valid ASCII? If it's only sometimes ASCII, is that worth noting? Under what circumstances do each of these outcomes occur? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's basically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it would be good to just say that? ¯\_(ツ)_/¯ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's a good call. |
||
|
||
See also [`content`](@ref). | ||
""" | ||
function rawcontent(blob::GitBlob) | ||
ptr = ccall((:git_blob_rawcontent, :libgit2), Ptr{UInt8}, (Ptr{Void},), blob.ptr) | ||
copy(unsafe_wrap(Array, ptr, (length(blob),), false)) | ||
end | ||
|
||
""" | ||
content(blob::GitBlob) | ||
content(blob::GitBlob) -> String | ||
|
||
Fetch the contents of the `GitBlob` `blob`. If the `blob` contains | ||
Fetch the contents of the [`GitBlob`](@ref) `blob`. If the `blob` contains | ||
binary data (which can be determined using [`isbinary`](@ref)), | ||
throw an error. Otherwise, return a `String` containing the contents | ||
of the `blob`. | ||
|
@@ -24,6 +33,8 @@ function content(blob::GitBlob) | |
end | ||
|
||
""" | ||
isbinary(blob::GitBlob) -> Bool | ||
|
||
Use a heuristic to guess if a file is binary: searching for NULL bytes and | ||
looking for a reasonable ratio of printable to non-printable characters among | ||
the first 8000 bytes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
Vector{UInt8}
(assuming that's true)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done