MCPcopy Create free account
hub / github.com/libgit2/pygit2 / CheckoutCallbacks

Class CheckoutCallbacks

pygit2/callbacks.py:266–325  ·  view source on GitHub ↗

Base class for pygit2 checkout callbacks. Inherit from this class and override the callbacks that you want to use in your class, which you can then pass to checkout operations.

Source from the content-addressed store, hash-verified

264
265
266class CheckoutCallbacks(Payload):
267 """Base class for pygit2 checkout callbacks.
268
269 Inherit from this class and override the callbacks that you want to use
270 in your class, which you can then pass to checkout operations.
271 """
272
273 def __init__(self) -> None:
274 super().__init__()
275
276 def checkout_notify_flags(self) -> CheckoutNotify:
277 """
278 Returns a bit mask of the notifications to receive from a checkout
279 (a combination of enums.CheckoutNotify constants).
280
281 By default, if you override `checkout_notify`, all notifications will
282 be enabled. You can fine tune the notification types to enable by
283 overriding `checkout_notify_flags`.
284
285 Please note that the flags are only sampled once when checkout begins.
286 You cannot change the flags while a checkout is in progress.
287 """
288 if type(self).checkout_notify == CheckoutCallbacks.checkout_notify:
289 # If the user hasn't overridden the notify function,
290 # filter out all notifications.
291 return CheckoutNotify.NONE
292 else:
293 # If the user provides their own notify function,
294 # enable all notifications by default.
295 return CheckoutNotify.ALL
296
297 def checkout_notify(
298 self,
299 why: CheckoutNotify,
300 path: str,
301 baseline: Optional[DiffFile],
302 target: Optional[DiffFile],
303 workdir: Optional[DiffFile],
304 ) -> None:
305 """
306 Checkout will invoke an optional notification callback for
307 certain cases - you pick which ones via `checkout_notify_flags`.
308
309 Raising an exception from this callback will cancel the checkout.
310 The exception will be propagated back and raised by the
311 ``Repository.checkout_...`` call.
312
313 Notification callbacks are made prior to modifying any files on disk,
314 so canceling on any notification will still happen prior to any files
315 being modified.
316 """
317 pass
318
319 def checkout_progress(
320 self, path: str, completed_steps: int, total_steps: int
321 ) -> None:
322 """
323 Optional callback to notify the consumer of checkout progress.

Callers 1

_git_checkout_optionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…