MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / delete_branch

Method delete_branch

github/PullRequest.py:864–874  ·  view source on GitHub ↗

Convenience function that calls :meth:`GitRef.delete` :rtype: bool.

(self, force: bool = False)

Source from the content-addressed store, hash-verified

862 return self.head.repo.create_git_ref(f"refs/heads/{self.head.ref}", sha=self.head.sha)
863
864 def delete_branch(self, force: bool = False) -> None:
865 """
866 Convenience function that calls :meth:`GitRef.delete` :rtype: bool.
867 """
868 if not force:
869 remaining_pulls = self.head.repo.get_pulls(head=f"{self.head.repo.owner.login}:{self.head.ref}")
870 if remaining_pulls.totalCount > 0:
871 raise RuntimeError(
872 "This branch is referenced by open pull requests, set force=True to delete this branch."
873 )
874 return self.head.repo.get_git_ref(f"heads/{self.head.ref}").delete()
875
876 def enable_automerge(
877 self,

Callers 3

mergeMethod · 0.95
testDeleteBranchMethod · 0.80
testForceDeleteBranchMethod · 0.80

Calls 3

get_git_refMethod · 0.80
get_pullsMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected