【问题标题】:Remote response when pushing with LibGit2Sharp使用 LibGit2Sharp 推送时的远程响应
【发布时间】:2014-03-03 14:54:21
【问题描述】:

在 LibGit2Sharp 中是否有在进行推送时获得远程响应?

当使用 git bash 命令行之类的东西时,您会在控制台中获得以下输出:

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.

PushOptions 在推送操作期间提供包构建、传输和错误状态,但理想情况下,我想捕获远程响应(如上所列)并将其反馈给客户端。有什么办法可以用 libgit2 / LibGit2Sharp 做到这一点?

这是我使用 LibGit2Sharp 版本 0.16.0.0 的 Push 操作的 sn-p

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);
}

【问题讨论】:

    标签: libgit2 libgit2sharp


    【解决方案1】:

    该信息是由服务器进程在称为“进度”的特定通道中发送的,这需要双方达成支持此扩展的协议。 libgit2 本身已经学会了如何做到这一点,但 libgit2sharp 尚未更新以支持这个额外的频道。

    一旦完成,它将看起来像 FetchOnProgress

    【讨论】:

    • @sitereactor:也许你可以打开一个功能请求,以便项目可以跟踪这个?
    • @nulltoken 是的,我会这样做。还将查看 Fetch OnProgress 功能,看看我是否能够弄清楚应该如何实现类似的东西(对于 Push OnProgress),在这种情况下我将提交一个 Pull Request。
    • @sitereactor:太棒了!我们很乐意帮助您看到这样的拉取请求合并。
    猜你喜欢
    • 1970-01-01
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-29
    • 1970-01-01
    • 1970-01-01
    • 2010-10-31
    • 1970-01-01
    相关资源
    最近更新 更多