T
- the return type which is expected from call()
public abstract class GitHook<T> extends Object implements Callable<T>
Modifier | Constructor and Description |
---|---|
protected |
GitHook(Repository repo,
OutputStream outputStream)
Constructor for GitHook.
|
protected |
GitHook(Repository repo,
OutputStream outputStream,
OutputStream errorStream)
Constructor for GitHook
|
Modifier and Type | Method and Description |
---|---|
abstract T |
call() |
protected void |
doRun()
Runs the hook, without performing any validity checks.
|
protected OutputStream |
getErrorStream()
Get error stream
|
abstract String |
getHookName()
Get name of the hook
|
protected OutputStream |
getOutputStream()
Get output stream
|
protected String[] |
getParameters()
Override this method when needed to provide relevant parameters to the
underlying hook script.
|
protected Repository |
getRepository()
Get the repository
|
protected String |
getStdinArgs()
Override to provide relevant arguments via stdin to the underlying hook
script.
|
protected void |
handleError(String message,
ProcessResult result)
Process that the hook exited with an error.
|
boolean |
isNativeHookPresent()
Check whether a 'native' (i.e.
|
protected GitHook(Repository repo, OutputStream outputStream)
This constructor will use stderr for the error stream.
repo
- a Repository
object.outputStream
- The output stream the hook must use. null
is allowed,
in which case the hook will use System.out
.protected GitHook(Repository repo, OutputStream outputStream, OutputStream errorStream)
repo
- a Repository
object.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
.public abstract T call() throws IOException, AbortedByHookException
Run the hook.
call
in interface Callable<T>
IOException
AbortedByHookException
public abstract String getHookName()
null
.protected Repository getRepository()
protected String[] getParameters()
protected String getStdinArgs()
null
.protected OutputStream getOutputStream()
null
,
System.out
is returned by default.protected OutputStream getErrorStream()
null
,
System.err
is returned by default.protected void doRun() throws AbortedByHookException, IOException
AbortedByHookException
- If the underlying hook script exited with non-zero.IOException
- if an IO error occurredprotected void handleError(String message, ProcessResult result) throws AbortedByHookException
AbortedByHookException
. Hooks which need a different
behavior can overwrite this method.message
- error messageresult
- The process result of the hookAbortedByHookException
- When the hook should be abortedpublic boolean isNativeHookPresent()
Copyright © 2021 Eclipse JGit Project. All rights reserved.