【发布时间】:2013-02-06 06:34:38
【问题描述】:
我们不是在谈论 SSH,因为它尚未实现,但是在通过 HTTP/HTTPS 执行获取之前,如何为存储库提供凭据? Credentials 实例似乎没有参数,在构建用于存储凭据的 Repository 实例时也没有任何参数。
【问题讨论】:
标签: libgit2sharp
我们不是在谈论 SSH,因为它尚未实现,但是在通过 HTTP/HTTPS 执行获取之前,如何为存储库提供凭据? Credentials 实例似乎没有参数,在构建用于存储凭据的 Repository 实例时也没有任何参数。
【问题讨论】:
标签: libgit2sharp
在 FetchFixture.cs 文件中,有一个 Fetch() test using credentials:
[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
}
});
}
}
【讨论】: