将默认 github 分支更改为 Octokit.net

Change default github branch with Octokit.net

我有一个小项目用于更新 GitHub 存储库中的各种设置。尽管我找到了存储库,但 Edit 方法抛出 NotFoundException。有什么建议可能是错的吗? 我正在从 "master" 更改为 "develop",两者都存在。

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);
}

您必须检查您是否有权限(像往常一样)。如果导航面包屑中没有"Settings",则说明您没有权限。

为什么Octokit.netreturnsNotFoundException, rather than AuthorizationException是另一个故事。