Package org.eclipse.jgit.hooks
Class CommitMsgHook
- java.lang.Object
-
- org.eclipse.jgit.hooks.GitHook<String>
-
- org.eclipse.jgit.hooks.CommitMsgHook
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CommitMsgHook(Repository repo, PrintStream outputStream)
Constructor for CommitMsgHookprotected
CommitMsgHook(Repository repo, PrintStream outputStream, PrintStream errorStream)
Constructor for CommitMsgHook
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
call()
String
getHookName()
Get name of the hookprotected String[]
getParameters()
Override this method when needed to provide relevant parameters to the underlying hook script.CommitMsgHook
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 Detail
-
NAME
public static final String NAME
Constant indicating the name of the commit-smg hook.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CommitMsgHook
protected CommitMsgHook(Repository repo, PrintStream outputStream)
Constructor for CommitMsgHookThis constructor will use the default error stream.
- Parameters:
repo
- The repositoryoutputStream
- The output stream the hook must use.null
is allowed, in which case the hook will useSystem.out
.
-
CommitMsgHook
protected CommitMsgHook(Repository repo, PrintStream outputStream, PrintStream errorStream)
Constructor for CommitMsgHook- Parameters:
repo
- The repositoryoutputStream
- The output stream the hook must use.null
is allowed, in which case the hook will useSystem.out
.errorStream
- The error stream the hook must use.null
is allowed, in which case the hook will useSystem.err
.- Since:
- 5.6
-
-
Method Detail
-
call
public String call() throws IOException, AbortedByHookException
Run the hook.
- Specified by:
call
in interfaceCallable<String>
- Specified by:
call
in classGitHook<String>
- Throws:
IOException
AbortedByHookException
-
getHookName
public String getHookName()
Get name of the hook- Specified by:
getHookName
in classGitHook<String>
- Returns:
- The name of the hook, which must not be
null
.
-
getParameters
protected String[] 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:
getParameters
in classGitHook<String>
- Returns:
- The parameters the hook receives.
-
setCommitMessage
public CommitMsgHook setCommitMessage(String commitMessage)
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:
this
for convenience.
-
-