1
在LibGit2Sharp中是否有在执行推送时获取远程响应?使用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
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);
}
@sitereactor:也许你可以打开一个功能请求,以便项目可以跟踪这个? – nulltoken
@nulltoken是的,我会那样做的。还会看看Fetch OnProgress功能,看看我是否能够弄清楚应该如何实现类似的事情(对于Push OnProgress),在这种情况下,我会提交一个Pull Request。 – sitereactor
@sitereactor:太棒了!我们很乐意帮助您看到合并的拉动请求。 – nulltoken