我希望能够显示我的 Github 个人资料中的所有提交,我确实设法列出了一个 repo 的 repos 和提交,但不能全部列出。
错误消息 下面是我的代码:
public IReadOnlyList<Repository> Repositories { get; set; }
public IReadOnlyList<GitHubCommit> Commits = new List<GitHubCommit>();
public async Task OnGetAsync()
{
if (User.Identity.IsAuthenticated)
{
GitHubName = User.FindFirst(c => c.Type == ClaimTypes.Name)?.Value;
GitHubLogin = User.FindFirst(c => c.Type == "urn:github:login")?.Value;
GitHubUrl = User.FindFirst(c => c.Type == "urn:github:url")?.Value;
GitHubAvatar = User.FindFirst(c => c.Type == "urn:github:avatar")?.Value;
string accessToken = await HttpContext.GetTokenAsync("access_token");
var github = new GitHubClient(new ProductHeaderValue("CommitView"), new InMemoryCredentialStore(new Credentials(accessToken)));
Repositories = await github.Repository.GetAllForCurrent();
foreach (var reppo in Repositories)
{
var repoCommits = await github.Repository.Commit.GetAll(reppo.Id);
Commits.Append(repoCommits);
}
}
}