我克隆了:
https://github.com/libgit2/libgit2sharp
据我所知,这是TFS 2015中使用的git客户端。我正在试着做测试:
public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)在:
https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp.Tests/CloneFixture.cs
在这里,我更新了它以使用TFS中的Git存储库:
[Theory]
//[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
[InlineData("http://tfs/tfs/collection/project/_git/MyRepo", "myUser", "myPass", false)]
// [InlineData("http://tfs/tfs/collection/project/_git/MyRepo", "myUser", "myPass", true)]
public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
{
var scd = BuildSelfCleaningDirectory();
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
{
CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials (user, pass, secure)
});
using (var repo = new Repository(clonedRepoPath))但是,当我运行测试时,我会得到以下异常:
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in c:\tmp\Repos\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 160
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in c:\tmp\Repos\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 178
at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in c:\tmp\Repos\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 328
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in c:\tmp\Repos\libgit2sharp\LibGit2Sharp\Repository.cs:line 694
at LibGit2Sharp.Tests.CloneFixture.CanCloneFromBBWithCredentials(String url, String user, String pass, Boolean secure) in c:\tmp\Repos\libgit2sharp\LibGit2Sharp.Tests\CloneFixture.cs:line 227我已经验证了我可以使用上面提供的userName和密码从命令行使用:https://git-scm.com/克隆存储库。
对于如何在TFS 2015 Git存储库上运行libgit2sharp测试,有什么想法吗?
发布于 2015-11-09 18:31:21
DefaultCredentials类型是您所追求的,因为TFS协议不依赖用户名和密码进行身份验证。
正如xml文档所指出的,它是“一个凭据对象,它将通过NTLM或SPNEGO身份验证提供”默认“凭据(登录用户信息)”。
将CloneOptions.CredentialsProvider设置为下面的内容应该可以做到这一点
CredentialsProvider = (_url, _user, _cred) => new DefaultCredentials()https://stackoverflow.com/questions/33612253
复制相似问题