Pergunta

In LibGit2Sharp is there anyway to get the remote response when doing a Push?

When using something like the git bash command line you get the following output in the console:

remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '3fe0a458ac'.
remote: Generating deployment script.
remote: Running deployment command...
remote: Handling Basic Web Site deployment.

The PushOptions provides pack building, transfer and error status during a Push operation, but ideally I'd like to catch the remote response (as listed above) and feed that back to the client. Any way to do this with libgit2 / LibGit2Sharp ?

Here is a snippet of my Push action using LibGit2Sharp version 0.16.0.0

using (var repository = new Repository(sourceRepositoryPath))
{
    var pushOptions = new PushOptions
    {
        Credentials = new Credentials { Username = remoteUser, Password = remotePassword },
        OnPackBuilderProgress = (stage, current, total) =>
        {
            Trace.WriteLine(string.Format("Pack Building Progress {0} out of {1}, Stage {2}",
                current, total, stage));
            return true;
        },
        OnPushStatusError = errors =>
        {
            Trace.WriteLine(errors);
        },
        OnPushTransferProgress = (current, total, bytes) =>
        {
            Trace.WriteLine(string.Format("Transfer Progress {0} out of {1}, Bytes {2}", current, total, bytes));
            return true;
        }
    };
    string pushRefSpec = string.Format("+{0}:{0}", "refs/heads/master");
    var remote = repository.Network.Remotes["origin"];
    repository.Network.Push(remote, pushRefSpec, pushOptions);
}
Foi útil?

Solução

That information is being sent by the server process in a particular channel called 'progress', which requires an agreement between both parties that they support this extension. libgit2 itself has learnt how to do this, but libgit2sharp hasn't been updated yet to support this extra channel.

Once it does, it would look like Fetch's OnProgress.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top