首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LibGit2Sharp和TFS Git存储库

LibGit2Sharp和TFS Git存储库
EN

Stack Overflow用户
提问于 2015-11-09 15:15:58
回答 1查看 1K关注 0票数 0

我克隆了:

https://github.com/libgit2/libgit2sharp

据我所知,这是TFS 2015中使用的git客户端。我正在试着做测试:

代码语言:javascript
复制
   public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)

在:

https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp.Tests/CloneFixture.cs

在这里,我更新了它以使用TFS中的Git存储库:

代码语言:javascript
复制
    [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))

但是,当我运行测试时,我会得到以下异常:

代码语言:javascript
复制
   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测试,有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-09 18:31:21

DefaultCredentials类型是您所追求的,因为TFS协议不依赖用户名和密码进行身份验证。

正如xml文档所指出的,它是“一个凭据对象,它将通过NTLM或SPNEGO身份验证提供”默认“凭据(登录用户信息)”。

CloneOptions.CredentialsProvider设置为下面的内容应该可以做到这一点

代码语言:javascript
复制
CredentialsProvider = (_url, _user, _cred) => new DefaultCredentials()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33612253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档