简体   繁体   中英

Change default github branch with Octokit.net

I have a small project for updating various settings in GitHub repos. Although I find the repo, the Edit method throws NotFoundException. Any suggestions what could be wrong? I'm changing from "master" to "develop", both exists.

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

You have to check if you have permissions (as usual). If there is no "Settings" in the navigation breadcrumb, you don't have permission.

Why Octokit.net returns NotFoundException , rather than AuthorizationException is another story.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM