The
commit-msg hook implementation. This hook is run before the
commit and can reject the commit. It passes one argument to the hook script,
which is the path to the COMMIT_MSG file, relative to the repository
workTree.- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCommitMsgHook(Repository repo, PrintStream outputStream) Constructor for CommitMsgHookprotectedCommitMsgHook(Repository repo, PrintStream outputStream, PrintStream errorStream) Constructor for CommitMsgHook -
Method Summary
Modifier and TypeMethodDescriptioncall()Get name of the hookprotected String[]Override this method when needed to provide relevant parameters to the underlying hook script.setCommitMessage(String commitMessage) It is mandatory to call this method with a non-null value before actually calling the hook.Methods inherited from class org.eclipse.jgit.hooks.GitHook
doRun, getErrorStream, getOutputStream, getRepository, getStdinArgs, handleError, isNativeHookPresent
-
Field Details
-
NAME
Constant indicating the name of the commit-smg hook.- See Also:
-
-
Constructor Details
-
CommitMsgHook
Constructor for CommitMsgHookThis constructor will use the default error stream.
- Parameters:
repo- The repositoryoutputStream- The output stream the hook must use.nullis allowed, in which case the hook will useSystem.out.
-
CommitMsgHook
Constructor for CommitMsgHook- Parameters:
repo- The repositoryoutputStream- The output stream the hook must use.nullis allowed, in which case the hook will useSystem.out.errorStream- The error stream the hook must use.nullis allowed, in which case the hook will useSystem.err.- Since:
- 5.6
-
-
Method Details
-
call
Description copied from class:GitHookRun the hook.
- Specified by:
callin interfaceCallable<String>- Specified by:
callin classGitHook<String>- Throws:
IOExceptionAbortedByHookException
-
getHookName
Description copied from class:GitHookGet name of the hook- Specified by:
getHookNamein classGitHook<String>- Returns:
- The name of the hook, which must not be
null.
-
getParameters
Override this method when needed to provide relevant parameters to the underlying hook script. The default implementation returns an empty array. This hook receives one parameter, which is the path to the file holding the current commit-msg, relative to the repository's work tree.- Overrides:
getParametersin classGitHook<String>- Returns:
- The parameters the hook receives.
-
setCommitMessage
It is mandatory to call this method with a non-null value before actually calling the hook.- Parameters:
commitMessage- The commit message before the hook has run.- Returns:
thisfor convenience.
-