PostReceiveHook.java

  1. /*
  2.  * Copyright (C) 2008, Google Inc. and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.transport;

  11. import java.util.Collection;

  12. /**
  13.  * Hook invoked by {@link org.eclipse.jgit.transport.ReceivePack} after all
  14.  * updates are executed.
  15.  * <p>
  16.  * The hook is called after all commands have been processed. Only commands with
  17.  * a status of {@link org.eclipse.jgit.transport.ReceiveCommand.Result#OK} are
  18.  * passed into the hook. To get all commands within the hook, see
  19.  * {@link org.eclipse.jgit.transport.ReceivePack#getAllCommands()}.
  20.  * <p>
  21.  * Any post-receive hook implementation should not update the status of a
  22.  * command, as the command has already completed or failed, and the status has
  23.  * already been returned to the client.
  24.  * <p>
  25.  * Hooks should execute quickly, as they block the server and the client from
  26.  * completing the connection.
  27.  */
  28. public interface PostReceiveHook {
  29.     /** A simple no-op hook. */
  30.     PostReceiveHook NULL = (final ReceivePack rp,
  31.             final Collection<ReceiveCommand> commands) -> {
  32.         // Do nothing.
  33.     };

  34.     /**
  35.      * Invoked after all commands are executed and status has been returned.
  36.      *
  37.      * @param rp
  38.      *            the process handling the current receive. Hooks may obtain
  39.      *            details about the destination repository through this handle.
  40.      * @param commands
  41.      *            unmodifiable set of successfully completed commands. May be
  42.      *            the empty set.
  43.      */
  44.     void onPostReceive(ReceivePack rp,
  45.             Collection<ReceiveCommand> commands);
  46. }