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
11 package org.eclipse.jgit.transport;
12
13 import java.util.Collection;
14
15 /**
16 * Hook invoked by {@link org.eclipse.jgit.transport.ReceivePack} after all
17 * updates are executed.
18 * <p>
19 * The hook is called after all commands have been processed. Only commands with
20 * a status of {@link org.eclipse.jgit.transport.ReceiveCommand.Result#OK} are
21 * passed into the hook. To get all commands within the hook, see
22 * {@link org.eclipse.jgit.transport.ReceivePack#getAllCommands()}.
23 * <p>
24 * Any post-receive hook implementation should not update the status of a
25 * command, as the command has already completed or failed, and the status has
26 * already been returned to the client.
27 * <p>
28 * Hooks should execute quickly, as they block the server and the client from
29 * completing the connection.
30 */
31 public interface PostReceiveHook {
32 /** A simple no-op hook. */
33 PostReceiveHook NULL = (final ReceivePack rp,
34 final Collection<ReceiveCommand> commands) -> {
35 // Do nothing.
36 };
37
38 /**
39 * Invoked after all commands are executed and status has been returned.
40 *
41 * @param rp
42 * the process handling the current receive. Hooks may obtain
43 * details about the destination repository through this handle.
44 * @param commands
45 * unmodifiable set of successfully completed commands. May be
46 * the empty set.
47 */
48 void onPostReceive(ReceivePack rp,
49 Collection<ReceiveCommand> commands);
50 }