使用 Octokit.net 更改默认 github 分支



>我有一个用于更新 GitHub 存储库中各种设置的小项目。虽然我找到了存储库,但 Edit 方法抛出了 NotFoundException。任何建议可能出了什么问题? 我正在从"主人"变成"发展",两者都存在。

public async Task<Repository> SetDefaultBranch(string repository, string branch)
{
//var repo = await _client.Repository.Get(_owner, update.Name);
// the repo is found, but afterwards I receive NotFoundException on Edit
var update = new RepositoryUpdate(repository) { DefaultBranch = branch };
return await _client.Repository.Edit(_owner, repository, update);
}

您必须检查您是否具有权限(像往常一样(。如果导航痕迹导航中没有"设置",则您没有权限。

为什么 Octokit.net 返回NotFoundException,而不是AuthorizationException是另一回事。

最新更新