Search code examples
github-apioctokit.net

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

Solution

  • 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.