Interface RepositoryHookCommitCallback

All Known Subinterfaces:
PreRepositoryHookCommitCallback

public interface RepositoryHookCommitCallback
A callback to receive more information about commits added or removed in a RepositoryHookRequest. The callback will be called for each each relevant (ref, commit) pair:
  • For added refs, only new commits are provided to onCommitAdded(CommitAddedDetails). For new refs that point to existing commits, no commits are provided to the callback.
  • For deleted refs, only commits that are removed from the repository (orphaned) are provided onCommitRemoved(CommitRemovedDetails).
  • For updated refs, all commits that are added or removed to that ref are provided to the callback.
Multiple callbacks can occur for the same commit. For instance, when branch A is merged into branch B and branch B is merged into branch C, a commit that was previously only on branch A will now be on branch A, B and C. In this case, onCommitAdded(CommitAddedDetails) is called for both branch B and C.

The system will call onStart() before the first commit details are provided to the callback to allow the hook to initialize. Likewise, the system calls onEnd() after the last commit details have been provided to the callback. This can be because all commit details have been provided, the callback has returned false from one of the callback methods to instruct the system that it's done processing commits, or - in the case of pre-hooks - because the request has been vetoed and no further commit processing will be done.

If a RepositoryHookRequest is vetoed in PreRepositoryHook.preUpdate(PreRepositoryHookContext, RepositoryHookRequest) before commit details are retrieved, callbacks will not be called at all; the onStart() and onEnd() methods will not be called. However, if the onStart() method is called, the system will also call the onEnd() method at the end of processing.

Since:
5.0
  • Method Details

    • onCommitAdded

      default boolean onCommitAdded(@Nonnull CommitAddedDetails commitDetails)
      Parameters:
      commitDetails - the commit details
      Returns:
      true if the callback wants to receive details about added and removed commits. Otherwise false. When this method returns false, neither this method nor onCommitRemoved(CommitRemovedDetails) will be called with further commit details.
    • onCommitRemoved

      default boolean onCommitRemoved(@Nonnull CommitRemovedDetails commitDetails)
      Parameters:
      commitDetails - the commit details
      Returns:
      true if the callback wants to receive details about added and removed commits. Otherwise false. When this method returns false, neither this method nor onCommitAdded(CommitAddedDetails) will be called with further commit details.
    • onEnd

      default void onEnd()
      Callback method that is called after all commits have been offered to the callback. The callback can perform any cleanup operations here. If onStart() has been called, this method is guaranteed to be called when the callback has finished commit processing.
    • onStart

      default void onStart()
      Callback method that is called before the commits details are provided to onCommitAdded(CommitAddedDetails) and onCommitRemoved(CommitRemovedDetails)