-
-
Notifications
You must be signed in to change notification settings - Fork 276
show a progress bar when cloning git repos #177
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
Conversation
89f4b01
to
8dfb2db
Compare
8dfb2db
to
78b8142
Compare
src/GitTools.jl
Outdated
|
||
function transfer_progress(progress::Ptr{GitTransferProgress}, p::Any) | ||
progress = unsafe_load(progress) | ||
bar = unsafe_pointer_to_objref(p.transfer_progress) |
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.
@omus I would have assumed that the payload sent to this function was supposed to be the p.transfer_progress
instead of the whole struct (since those are given together to RemoteCallbacks
).
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.
I forgot to update this code with my Pkg3.jl PR. This will need to be changed to:
transfer_progress_ptr = LibGit2.payload_unpack(p, :transfer_progress)
@assert transfer_progress_ptr != C_NULL
bar = unsafe_pointer_to_objref(transfer_progress_ptr)
At the moment if you use the tuple syntax for RemoteCallbacks
it breaks apart the tuple and puts each of the payloads inside of a RemotePayloads
container. I decided that having each callback unpack this object was the better solution instead of unwrapping it before calling the user's callback.
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.
I decided that having each callback unpack this object was the better solution instead of unwrapping it before calling the user's callback.
Alright.
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.
payload_unpack(p, :transfer_progress)
doesn't work because p
is an instance of RemotePayloads
and not a pointer to it (like payload_unpack
expects). I just added a p.transfer_progress != C_NULL
check.
I could change JuliaLang/julia#26437 to handle this more transparently. The reason I didn't go in this direction is because it would involve an extra |
In some sense that would be "cleaner" in that your callback get exactly the corresponding payload that you specified. On the other hand, maybe you want to look at the payloads for all the other callbacks? Doesn't matter too much to me :) |
src/GitTools.jl
Outdated
|
||
progress = unsafe_load(progress) | ||
@assert p.transfer_progress != C_NULL | ||
bar = unsafe_pointer_to_objref(p.transfer_progress) |
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.
If you define this function as transfer_progress(progress::Ptr{GitTransferProgress}, bar::MiniProgressBar)
you can perform the unsafe operations in another method like:
function transfer_progress(progress::Ptr{GitTransferProgress}, p::LibGit2.RemotePayloads)
transfer_progress(progress, unsafe_pointer_to_objref(p.transfer_progress))
end
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.
What's the advantage?
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.
May make the code slightly cleaner
I'll rebase this when nightlies are updated. |
This is a pretty slick feature 😁 |
* Use high-level clone/fetch with callback support * Use LibGit2.TransferProgress
03ad5a9
to
ec3c4a4
Compare
Mac and Linux nightlies are up, tests are passing, things are awesome 🎉. Thanks @omus, this is one nice milestone for improving the user-friendliness of the Julia package manager! |
* show a progress bar when cloning git repos and add credential handling
In the spirit of #89.
http://www.giphy.com/gifs/2rAET3llXUjR9pfUVO
Requires JuliaLang/julia#26387
cc @jperla