public class CommitMsgHook extends Object
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 |
|---|---|
static String |
NAME
Constant indicating the name of the commit-smg hook.
|
protected PrintStream |
outputStream
The output stream to be used by the hook.
|
| Modifier | Constructor and Description |
|---|---|
protected |
CommitMsgHook(Repository repo,
PrintStream outputStream) |
| Modifier and Type | Method and Description |
|---|---|
String |
call()
Run the hook.
|
protected void |
doRun()
Runs the hook, without performing any validity checks.
|
String |
getHookName() |
protected PrintStream |
getOutputStream() |
protected String[] |
getParameters()
This hook receives one parameter, which is the path to the file holding
the current commit-msg, relative to the repository's work tree.
|
protected Repository |
getRepository() |
protected String |
getStdinArgs()
Override to provide relevant arguments via stdin 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.
|
public static final String NAME
protected final PrintStream outputStream
protected CommitMsgHook(Repository repo, 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 String call() throws IOException, AbortedByHookException
call in interface Callable<String>IOException - if IO goes wrong.AbortedByHookException - If the hook has been run and a returned an exit code
different from zero.public String getHookName()
null.protected String[] getParameters()
public CommitMsgHook setCommitMessage(String commitMessage)
commitMessage - The commit message before the hook has run.this for convenience.protected Repository getRepository()
protected String getStdinArgs()
null.protected PrintStream getOutputStream()
null,
System.out is returned by default.protected void doRun()
throws AbortedByHookException
AbortedByHookException - If the underlying hook script exited with non-zero.Copyright © 2017 Eclipse JGit Project. All rights reserved.