libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

Repository.applies: new option `raise_error` #1166

Closed jorio closed 1 year ago

jorio commented 1 year ago

Repository.applies() checks if a patch can be applied to HEAD without writing it. Currently, it doesn't provide any info beyond a boolean return value.

This PR adds an optional argument raise_error to Repository.applies. If raise_error=True, an exception will be raised if the patch doesn't apply. This lets the user get more detailed info from libgit2 about the failure to apply the patch.

By default, raise_error is False, so any existing code that depends on Repository.applies will keep working without changes.