-
Notifications
You must be signed in to change notification settings - Fork 899
Fetch #221
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
Fetch #221
Conversation
@nulltoken @carlosmn : One thing I noticed is that it does not appear that all of the expected tags are being brought down as part of the fetch - In particular, the tag "annotated_tag" in @nulltoken's test repository is not being brought down as part of the fetch tests - if I do fetch from the PowerShell command line, it retrieves this particular tag. As of now, the tests included with this commit do not include this tag. |
I like the direction we're headed, but calling dahlbyk/libgit2sharp@jamill:Fetch...dahlbyk:Fetch Once the API is nailed down, Finally, within the existing test I've not been able to get a completion handler to actually fire. Even for a small test repository, that surprises me... |
@@ -221,6 +221,28 @@ public void CanListAllBranchesIncludingRemoteRefs() | |||
} | |||
|
|||
[Fact] | |||
public void CanResolveRemote() | |||
{ |
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.
Could you please split this test into three smaller ones?
This should allow you to have more explicit test method names and possibly get rid of the comments.
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.
Sure - will split this test.
@dahlbyk Thank you for the quick feedback!
The reason I was initially hesitant to go with this approach is that the RemoteCallbacks structure appears (to me) that it might be applicable more widely than just fetch at some point (These are callbacks set on the remote - they seem applicable to at least Pull and Fetch... not sure if all of these callbacks make sense with Push). Having said that, I am fine going with your API and will split out the callbacks.
Yes, this is why I did not expose this callback in my initial implementation. Unless I missed it, I actually do not see where this callback is called in libgit2. I included it so that when this functionality is added to libgit2, we should pick it up (albeit untested...) Maybe the correct thing to do is to not expose this callback until it is implemented in libgit2. (/cc @carlosmn) I will update the PR with the API you suggested, add Fetch to IRepository, and add the extension method taking the remote name. |
[Theory] | ||
[InlineData("http://github.com/nulltoken/TestGitRepository")] | ||
[InlineData("https://github.com/nulltoken/TestGitRepository")] | ||
//[InlineData("git@github.com:nulltoken/TestGitRepository")] |
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.
git://github.com/libgit2/TestGitRepository.git
should work
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.
The fetch test fails for this protocol, looks like this transport is not implemented yet:
LibGit2Sharp.Tests.RepositoryFixture.CanFetchFromEmptyRepository(url: "git@github.com:libgit2/TestGitRepository") [FAIL]
LibGit2Sharp.LibGit2SharpException : An error was raised by libgit2. Category = Net (Error).
This transport isn't implemented. Sorry
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.
- git read-only protocol (
git://github.com/libgit2/TestGitRepository.git
) should work. You might be willing to give it a try :wink2: - ssh (
git@github.com:libgit2/TestGitRepository
) is indeed not implemented yet
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 are correct - I will add the git read-only protocol to the set of tests that are run.
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.
Strange, I updated the InlineData content to the following
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
Here's the result of the test run
------ Test started: Assembly: LibGit2Sharp.Tests.dll ------
Test 'LibGit2Sharp.Tests.RepositoryFixture.CanFetchFromEmptyRepository(url: "git://github.com/libgit2/TestGitRepository.git")' failed:
Could not find the reference refs/tags/annotated_tag in the list of expected reference updates.
RepositoryFixture.cs(546,0): at LibGit2Sharp.Tests.RepositoryFixture.ExpectedFetchState.RemoteUpdateTipsHandler(String referenceName, ObjectId oldId, ObjectId newId)
RemoteCallbacks.cs(123,0): at LibGit2Sharp.RemoteCallbacks.GitUpdateTipsHandler(IntPtr str, GitOid& oldId, GitOid& newId, IntPtr data)
at LibGit2Sharp.Core.NativeMethods.git_remote_update_tips(RemoteSafeHandle remote)
Core\Proxy.cs(1101,0): at LibGit2Sharp.Core.Proxy.git_remote_update_tips(RemoteSafeHandle remote)
Repository.cs(630,0): at LibGit2Sharp.Repository.FetchInternal(RemoteSafeHandle remoteHandle, Int64& bytes, GitIndexerStats& gitIndexerStats, Nullable`1 callbacks)
Repository.cs(450,0): at LibGit2Sharp.Repository.Fetch(Remote remote, FetchProgress progress, RemoteCallbacks callbacks)
RepositoryFixture.cs(105,0): at LibGit2Sharp.Tests.RepositoryFixture.CanFetchFromEmptyRepository(String url)
2 passed, 1 failed, 0 skipped, took 7,32 seconds (xUnit.net 1.9.0 build 1566).
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.
yes :)
It appears that the git read-only protocol correctly fetches the expected references. I will update the expected results with the correct expected results. This means that the git read-only protocol will pass while http / https will fail.
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.
The fix for fetching from empty repos broke capability detection in HTTP (and probably cloning, come to think of it). I'm fixing this in the library now.
@jamill @dahlbyk I'm playing with an idea: moving the |
I can replicate this as well. @carlosmn is going to investigate this further. |
The reason I implemented |
I understand your point. However, I'm not sure that I'm willing to support temporary, in-memory nameless remotes in the near future. I haven't found a clear use case yet where a non persisted remote is a compelling requirement. |
I see - thank you for the explaination :) Yes, in that case I do not have any objections to putting the |
[InlineData("http://github.com/nulltoken/TestGitRepository")] | ||
[InlineData("https://github.com/nulltoken/TestGitRepository")] | ||
//[InlineData("git@github.com:nulltoken/TestGitRepository")] | ||
public void CanFetchFromEmptyRepository(string url) |
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.
BTW, I'm not sure the name of this test fully reflects its content ;) ^^
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 will change this to CanFetchIntoAnEmptyRepository
- (when originally naming this, my thought was "we are executing fetch from (inside of) an empty repository"
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.
👍
@nulltoken @dahlbyk : I have updated the Pull Request based on your feedback. The travis build failed due to the differences in the expected vs actual tags fetched. This update includes several changes:
I have added a bit of infrastructure around the fetch tests (for specifying and verifying expected references). If you have suggestions on a different approach you would like here, please let me know. Thanks again for taking the time to look at this PR and provide feedback. |
I cannot update the binaries yet with @carlosmn's fix. A small issue prevents the latest development tip from being compiled by MSVC with |
@jamill Sorry. No news on this front yet. None of the @schu confirmed the issue ("win32/pthread* is lacking the corresponding wrappers") /cc @phkelley |
That won't be necessary.
I actually fetch specific branches by URL quite a bit to look at PRs from individuals that haven't earned a spot in my remote list. (I'd love to see a "Fetch This Branch in GH4W" button.) git.git just leaves the reference in |
@dahlbyk Thanks again!
I agree - removed.
Thanks... fixed.
I made this class internal. I moved the delegate definitions over to the |
Now that you mention it, the nested delegates are probably why I didn't mark it internal myself. Having them live on Remote makes sense for Fetch as implemented now, but less so if they're also used for Clone or Fetch(url). If we don't want to pollute the root namespace, we could add a Handlers namespace where delegates live (since they're rarely needed by name thanks to inference). |
I added the delegate definitions into a Thanks again! |
@nulltoken looks like this issue was resolved with libgit2/libgit2#987. Would the next step be to update the libgit2 binaries and re-run the tests? |
@jamill @dahlbyk I'm not really sure about the discoverability of the definition of these handlers if we put them in a different namespace. Not everyone has got ReSharper... However, we know/hope that the API is going to change (cf. this comment), so let's keep it that way for now. |
I'm on it! ;) |
@jamill ...and done! Just a few things, I've noticed:
I was thinking about something similar to
I'm really eager to merge this. This is a fantastic job! |
@nulltoken Thanks for updating
Sure - I will update the test here to perform an additional fetch and verify the results.
Just to make sure I understand, you are referring to the whitespace at the end of RepositoryFixture? I will remove that. Are there other places that you were referring to as well? Thanks again! |
Nevermind, I think I see what you mean. I will take care of these. |
Try running Those will be easier to cleanup once the squash is done. |
Ok - I have squashed the previous commits into a single commit. I still included several commits to break out the changes based on the rebase reaction and other recent changes. I can go ahead and squash these as well if preferred. @nulltoken commit be2be63 includes the changes for the GitIndexerStats. I am not sure if you have a preference for these objects being |
A man after my own heart... |
No need for R#: VS (since 2010 at least) will show a smart tag to add a missing namespace. Though really type inference in C# 3 and up makes explicit use of delegate types pretty rare in my experience. |
@jamill I manually merged your awesome pull request in ✨✨✨ |
Enable multiplexing if the server supports it. This allows us to give feedback to the user when the server is doing work and we're waiting for the pack data to arrive. References libgit2#221, libgit2#222
This is a continuation of the PR #213, but based off of vNext branch. I have included the original commit to show the changes between the original PR and this updated PR. I can squash the commits so only the last final commit will show up if that would be easier.
This includes reaction for the updates LibGit2Sharp code base, using delegates instead of events, and includes tests for retrieving tags.