【问题标题】:libgit2sharp unable to do a repository push - Unable to evaluate expression because the code is optimizedlibgit2sharp 无法进行存储库推送 - 无法评估表达式,因为代码已优化
【发布时间】:2015-05-29 17:01:01
【问题描述】:

使用存储库网络对象进行调试时,实例的快速监视告诉我所有线程都需要运行,这会导致标题中出现消息。不知道为什么会这样,但是在推送时我收到了这条消息。

这里真正的问题是为什么下面的推送与删除和重新添加遥控器相比不起作用。

代码如下 - 所有参数值均有效。对本地回购的承诺正在发挥作用。在删除和重新添加遥控器后,唯一有效的签名是使用遥控器。在下面这种情况下,分支是正确的。:

 private Repository GetGitRepo()
 {
      string path = Settings.GetSetting(Constants.GitRepositoryPath);

      Repository repo = new Repository(path);
            
      return repo;
 }

 using (var repo = GetGitRepo())
 {
      if(commit != null)
      {
          var options = new PushOptions();
          options.CredentialsProvider = new CredentialsHandler(
                  (_url, _user, _cred) => 
                   new UsernamePasswordCredentials() { Username = Settings.GetSetting(Constants.GitUsername), Password = Settings.GetSetting(Constants.GitPassword) });
                        
          repo.Network.Push(_workingBranch, options);
                            
      }

 }

还有其他人遇到过这个问题,或者知道我可能遗漏了什么吗?

提前致谢!

【问题讨论】:

  • 这条消息来自哪里?这听起来像是调试器会告诉你的消息,这意味着它与 libgit2sharp 无关。您是否从 libgit2sharp 获得异常? 来自 libgit2sharp 你有什么错误?
  • 你在调试什么代码?你的还是 LibGit2Sharp 本身?
  • 也许this questionthis post 会有所帮助?
  • 您是在调试 libgit2sharp 的调试版本还是零售版本?这是您在本地构建的 libgit2sharp 吗? “代码已优化”消息可能意味着您正在使用非调试版本...
  • 使用“零售”版本的 libgit2sharp 调试我的。 libgit2sharp 的范围是推送时抛出的消息,可能我的设置中的某些内容不正确或丢失。

标签: git libgit2sharp


【解决方案1】:

这就是最终奏效的方法。我认为问题中所述的消息掩盖了另一个问题。最终删除并重新添加遥控器最终成功了。代码贴在下面:

using (var repo = GetGitRepo())
{
    // clean remote by remove and re-add
    var remoteName = Settings.GetSetting(Constants.GitUsername);
    repo.Network.Remotes.Remove(remoteName);
    Remote remote = repo.Network.Remotes.Add(remoteName, Settings.GetSetting(Constants.GitServer));

    // build credentials to repo in PushOptions        
    var options = new PushOptions();
    options.CredentialsProvider = new CredentialsHandler(
                    (_url, _user, _cred) =>
                        new UsernamePasswordCredentials() { Username =   Settings.GetSetting(Constants.GitUsername), Password =   Settings.GetSetting(Constants.GitPassword) });

    var pushRefSpec = _workingBranch.CanonicalName;

    repo.Network.Push(remote, pushRefSpec, options);
}

【讨论】:

    猜你喜欢
    • 2016-08-15
    • 1970-01-01
    • 2011-03-27
    • 2012-06-14
    • 1970-01-01
    • 2012-07-11
    相关资源
    最近更新 更多