1

我们不是在谈论 SSH,因为它尚未实现,但是在通过 HTTP/HTTPS 执行获取之前,如何为存储库提供凭据?Credentials 实例似乎没有参数,在构建用于存储凭据的 Repository 实例时也没有任何参数。

4

1 回答 1

4

FetchFixture.cs文件中,有一个使用凭据的 Fetch() 测试

    [SkippableFact]
    public void CanFetchIntoAnEmptyRepositoryWithCredentials()
    {
        InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl),
            "Populate Constants.PrivateRepo* to run this test");

        string repoPath = InitNewRepository();

        using (var repo = new Repository(repoPath))
        {
            Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);

            // Perform the actual fetch
            repo.Network.Fetch(remote, new FetchOptions
            {
                Credentials = new Credentials
                    {
                        Username = Constants.PrivateRepoUsername,
                        Password = Constants.PrivateRepoPassword
                    }
            });
        }
    }
于 2013-02-06T07:05:24.643 回答