Class PreCommitHook

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Void>

    public class PreCommitHook
    extends GitHook<java.lang.Void>
    The pre-commit hook implementation. This hook is run before the commit and can reject the commit.
    Since:
    4.0
    • Field Detail

      • NAME

        public static final java.lang.String NAME
        The pre-commit hook name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PreCommitHook

        protected PreCommitHook​(Repository repo,
                                java.io.PrintStream outputStream)
        Constructor for PreCommitHook

        This constructor will use the default error stream.

        Parameters:
        repo - The repository
        outputStream - The output stream the hook must use. null is allowed, in which case the hook will use System.out.
      • PreCommitHook

        protected PreCommitHook​(Repository repo,
                                java.io.PrintStream outputStream,
                                java.io.PrintStream errorStream)
        Constructor for PreCommitHook
        Parameters:
        repo - The repository
        outputStream - The output stream the hook must use. null is allowed, in which case the hook will use System.out.
        errorStream - The error stream the hook must use. null is allowed, in which case the hook will use System.err.
        Since:
        5.6
    • Method Detail

      • call

        public java.lang.Void call()
                            throws java.io.IOException,
                                   AbortedByHookException

        Run the hook.

        Specified by:
        call in interface java.util.concurrent.Callable<java.lang.Void>
        Specified by:
        call in class GitHook<java.lang.Void>
        Throws:
        java.io.IOException
        AbortedByHookException
      • getHookName

        public java.lang.String getHookName()
        Get name of the hook
        Specified by:
        getHookName in class GitHook<java.lang.Void>
        Returns:
        The name of the hook, which must not be null.