我正在尝试使用以下
将LibGit2Sharp用于git push origin
using(var repo = new Repository("path\to\repo\.git"))
{
var commit = repo.Commit("Commit message", author, committer);
var options = new PushOptions{ CredentialsProvider = (u, s, t) => new UserNamePasswordCredentials { Username = "username", Password = "password" } };
repo.Network.Push(repo.Branches("master"), options);
}
我得到一个LibGit2SharpException说
其他信息:无法设置代理:参数不正确。
但是在git bash中我做git push origin
时一切都很好。
我们正在使用NTLM代理,我正在推送到内部网https远程URI。我已将代理配置为http://username:password@proxy.fqdn:80
,如下所示:
阅读this SO and links there后,似乎libgit2sharp应该找到代理参数就好了。有没有人得到这个工作behing ntlm?
我正在使用: Windows 7,LibGit2Sharp.0.22.0,Git 2.10.1.windows.1,bash 4.3.46,.net4.5.2
关于实现推动替代方案的任何想法/技巧也非常受欢迎!
答案 0 :(得分:0)
这来自" libgit2 src/transports/winhttp.c
",它直接调用Windows API WinHttpSetOption
function。
它传递WINHTTP_OPTION_PROXY
来设置或检索包含现有会话句柄或请求句柄上的代理数据的WINHTTP_PROXY_INFO
结构。
仅当ERROR_INVALID_PARAMETER
设置为低于WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL
的值时,该函数才会返回15000
(参数无效)。
我不知道为什么LibGit2Sharp有这个问题,但首先尝试设置环境变量HTTP_PROXY
& HTTPS_PROXY
(不是http.proxy
& https.proxy
),并确保为两个代理环境变量使用相同的http网址(而不是HTTPS_PROXY
的https网址)
关于此问题的官方libgit2错误是issue 2106,应该使用PR 3110和commit 1dc4491来解决。 但是,该修复程序不是版本的一部分。