你可以通过pygithub删除仓库吗?

问题描述

可以使用pygithub删除存储库吗? 例如,如this示例中所示,您可以像这样删除文件

repo = g.get_repo("userName/repoName")
contents = repo.get_contents("filename.txt",ref="test")
repo.delete_file(contents.path,"remove test",contents.sha,branch="test")

是否有类似的东西可以删除整个仓库?如果没有,如何通过github API做到这一点?

解决方法

pygithub documentation确实包含一个delete()方法,该方法调用了确切的GitHub repo DELETE API delete /repos/{owner}/{repo}

因此应该可以调用该方法,如PyGithub/PyGithub tests/Repository.py

repo = self.g.get_user().get_repo("TestPyGithub")
repo.delete()