public class CommitMsgHook extends GitHook<java.lang.String>
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.| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
commitMessage
The commit message.
|
static java.lang.String |
NAME
Constant indicating the name of the commit-smg hook.
|
outputStream| Modifier | Constructor and Description |
|---|---|
protected |
CommitMsgHook(Repository repo,
java.io.PrintStream outputStream)
Constructor for CommitMsgHook
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
call() |
private boolean |
canRun() |
private java.lang.String |
getCommitEditMessageFilePath() |
java.lang.String |
getHookName()
Get name of the hook
|
protected java.lang.String[] |
getParameters()
Override this method when needed to provide relevant parameters to the
underlying hook script.
|
CommitMsgHook |
setCommitMessage(java.lang.String commitMessage)
It is mandatory to call this method with a non-null value before actually
calling the hook.
|
doRun, getOutputStream, getRepository, getStdinArgs, isNativeHookPresentpublic static final java.lang.String NAME
private java.lang.String commitMessage
protected CommitMsgHook(Repository repo, java.io.PrintStream outputStream)
repo - The repositoryoutputStream - The output stream the hook must use. null is allowed,
in which case the hook will use System.out.public java.lang.String call()
throws java.io.IOException,
AbortedByHookException
Run the hook.
call in interface java.util.concurrent.Callable<java.lang.String>call in class GitHook<java.lang.String>java.io.IOExceptionAbortedByHookExceptionprivate boolean canRun()
true if and only if the path to the message commit file
is not null (which would happen in a bare repository) and the
commit message is also not null.public java.lang.String getHookName()
getHookName in class GitHook<java.lang.String>null.protected java.lang.String[] getParameters()
getParameters in class GitHook<java.lang.String>private java.lang.String getCommitEditMessageFilePath()
public CommitMsgHook setCommitMessage(java.lang.String commitMessage)
commitMessage - The commit message before the hook has run.this for convenience.