T
- the return type which is expected from call()
abstract class GitHook<T>
extends java.lang.Object
implements java.util.concurrent.Callable<T>
Modifier and Type | Field and Description |
---|---|
protected java.io.PrintStream |
errorStream
The error stream to be used by the hook.
|
protected java.io.PrintStream |
outputStream
The output stream to be used by the hook.
|
private Repository |
repo |
Modifier | Constructor and Description |
---|---|
protected |
GitHook(Repository repo,
java.io.PrintStream outputStream)
Constructor for GitHook.
|
protected |
GitHook(Repository repo,
java.io.PrintStream outputStream,
java.io.PrintStream 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 java.io.PrintStream |
getErrorStream()
Get error stream
|
abstract java.lang.String |
getHookName()
Get name of the hook
|
protected java.io.PrintStream |
getOutputStream()
Get output stream
|
protected java.lang.String[] |
getParameters()
Override this method when needed to provide relevant parameters to the
underlying hook script.
|
protected Repository |
getRepository()
Get the repository
|
protected java.lang.String |
getStdinArgs()
Override to provide relevant arguments via stdin to the underlying hook
script.
|
boolean |
isNativeHookPresent()
Check whether a 'native' (i.e.
|
private final Repository repo
protected final java.io.PrintStream outputStream
protected final java.io.PrintStream errorStream
protected GitHook(Repository repo, java.io.PrintStream 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, java.io.PrintStream outputStream, java.io.PrintStream 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 java.io.IOException, AbortedByHookException
Run the hook.
call
in interface java.util.concurrent.Callable<T>
java.io.IOException
AbortedByHookException
public abstract java.lang.String getHookName()
null
.protected Repository getRepository()
protected java.lang.String[] getParameters()
protected java.lang.String getStdinArgs()
null
.protected java.io.PrintStream getOutputStream()
null
,
System.out
is returned by default.protected java.io.PrintStream getErrorStream()
null
,
System.err
is returned by default.protected void doRun() throws AbortedByHookException
AbortedByHookException
- If the underlying hook script exited with non-zero.public boolean isNativeHookPresent()