-
Notifications
You must be signed in to change notification settings - Fork 768
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
plumbing: wire up contexts for Transport.AdvertisedReferences #246
Conversation
Failed checks are a flaky test (network access from the test to the internet) and fractional coverage decrease from the shifting error paths, which I'm inclined to ignore. |
Perhaps someone should disable them all together |
@@ -1032,7 +1032,7 @@ func (r *Remote) List(o *ListOptions) (rfs []*plumbing.Reference, err error) { | |||
|
|||
defer ioutil.CheckClose(s, &err) | |||
|
|||
ar, err := s.AdvertisedReferences() | |||
ar, err := s.AdvertisedReferencesContext(context.TODO()) |
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.
Hi, I was using go-git
package to do git ls-remote
check. But I found this command doesn't have a timeout configuration. I saw you were doing this action. That would be nice!
But why do you pass context.TODO()
to it? As far as I know, context.TODO()
ia an empty context. This means, git ls-remote
also doesn't have timeout. Could you explain it for me pls? Thanks in advance!
For me, I expect list
func also can be configured ctx
parameter, like this:
func (r *Remote) list(ctx context.Context, o *ListOptions) (rfs []*plumbing.Reference, err error) {
... ...
... ...
ar, err := s.AdvertisedReferencesContext(ctx)
if err != nil {
return nil, err
}
... ....
... ....
}
So that we can control git ls-remote
command timeout within several seconds. How do you think?
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.
FetchContext and PushContext exist, but there's no ListContext method. That's a reasonable thing to add, it's just not part of this PR, which is doing the plumbing.
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.
Thanks for your reply! Could you please also help add ListContext
func? Or may I submit a new PR based on your changes? But this requires your PR is merged, not sure how long it will take?
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'd put the API change in a separate MR. No idea how long it will take somebody to get around to merging this one.
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.
Hope this PR can be merged soon!!!! By the way, about API change PR, do you want to own it? If not, I can do it.
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.
Hi, could you please add a test as @mcuadros said so that this PR can be merged? Because in our environment, this feature is needed and lack of it iss causing some problems for us. Thanks in advance!
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.
You can do the API change, I don't need it myself.
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.
ok, thanks!
Sorry for the late review, I will happy to merge this if you add a test to ensure the context propagation. |
The existing tests already covered this reasonably well - I had just fixed them to ensure that context propagates, rather than ensuring that it does not. I made a second pass and added a couple more cases, did you have any more specific in mind? |
Any updates about this PR? |
We need a test that fails with the old behavior, to validate that we pass properly the context. |
The existing tests do this. For example, TestPlainCloneContextNonExistingOverExistingGitDirectory. Fixing those tests to defer cancel() instead of calling it immediately is functionally inverting the test so that it verifies the context is passed, instead of verifying that the context is not passed. |
…#246) * plumbing: wire up contexts for Transport.AdvertisedReferences * add more tests for context wiring
This is primarily for the sake of the http transport, which otherwise makes its first call without a context, causing context timeouts to not work if the remote is unresponsive.
Fixed up several tests which were getting this wrong. I am particularly fond of the ones which canceled the context and then proceeded to test that the function worked after being canceled.
The AdvertisedReferences function can be removed after this change, but this is technically breaking the API, since library users could call it, so it should really be deferred to v6.