Skip to content

Expose Push progress reporting#537

Merged
nulltoken merged 2 commits into
libgit2:vNextfrom
jamill:PushProgress
Oct 19, 2013
Merged

Expose Push progress reporting#537
nulltoken merged 2 commits into
libgit2:vNextfrom
jamill:PushProgress

Conversation

@jamill

@jamill jamill commented Oct 18, 2013

Copy link
Copy Markdown
Member

Expose push progress reporting and cancellation that was recently included in libgit2.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please update the xml doc as well?

@jamill

jamill commented Oct 18, 2013

Copy link
Copy Markdown
Member Author

Thank you @nulltoken for the review. Updated.

Comment thread LibGit2Sharp/NetworkExtensions.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I overlooked this earlier, but I think this param is no longer needed (neither is its xml documentation)

@nulltoken

Copy link
Copy Markdown
Member

One last nitpick, the following test doesn't pass. Is this because of the timer that had been added in libgit2 (BTW, could you add some xml doc on the handlers that are affected by this timer?) or because not all the transports invoke the transfer callback?

[Fact]
public void CanReportDuringPushing()
{
    string remoteRepoPath = InitNewRepository(true);

    Commit commit;

    using (var localRepo = new Repository(BareTestRepoPath))
    {
        commit = localRepo.Head.Tip;

        Remote remote = localRepo.Network.Remotes.Add("origin", remoteRepoPath);

        localRepo.Branches.Update(localRepo.Head,
            b => b.Remote = remote.Name,
            b => b.UpstreamBranch = localRepo.Head.CanonicalName);

        bool builderCallbackCalled = false;
        bool transferCallbackCalled = false;

        var pushOptions = new PushOptions
        {
            OnPackBuilderProgress = (stage, current, total) =>
            {
                builderCallbackCalled = true;
                return true;
            },
            OnPushTransferProgress = (current, total, bytes) =>
            {
                transferCallbackCalled = true;
                return true;
            }
        };

        localRepo.Network.Push(localRepo.Head, pushOptions: pushOptions);

        Assert.Equal(true, builderCallbackCalled);
        Assert.Equal(true, transferCallbackCalled);
    }

    using (var remoteRepo = new Repository(remoteRepoPath))
    {
        Assert.Equal(commit, remoteRepo.Head.Tip);
    }
}

@jamill

jamill commented Oct 19, 2013

Copy link
Copy Markdown
Member Author

Thanks!

I updated the documentation on the PushOptions to indicate that the frequency of the progress updates.

One last nitpick, the following test doesn't pass

This is because not all transports invoke the transfer callback (in this case, the local transport does not invoke the transfer callback). This is why I didn't include test coverage for the transfer progress callback originally (but did include a test that the packbuilder callback was invoked). We could add this to libgit2 and then update the test here when we take the corresponding update.

@nulltoken
nulltoken merged commit bd736e2 into libgit2:vNext Oct 19, 2013
@nulltoken

Copy link
Copy Markdown
Member

....98.....99....100% Merged!

💖 💥

@nulltoken

Copy link
Copy Markdown
Member

We could add this to libgit2

@jamill I've kept track of this in libgit2/libgit2#1902

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