Package org.eclipse.jgit.hooks
Class PrePushHook
- Direct Known Subclasses:
LfsPrePushHook
The
pre-push hook implementation. The pre-push hook runs during
git push, after the remote refs have been updated but before any objects have
been transferred.- Since:
- 4.2
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrePushHook(Repository repo, PrintStream outputStream) Constructor for PrePushHookprotectedPrePushHook(Repository repo, PrintStream outputStream, PrintStream errorStream) Constructor for PrePushHook -
Method Summary
Modifier and TypeMethodDescriptioncall()private booleancanRun()Get name of the hookprotected String[]Override this method when needed to provide relevant parameters to the underlying hook script.protected StringGet remote nameprotected StringOverride to provide relevant arguments via stdin to the underlying hook script.voidsetRefs(Collection<RemoteRefUpdate> toRefs) Set RefsvoidsetRemoteLocation(String location) Set remote locationvoidsetRemoteName(String name) Set remote nameMethods inherited from class org.eclipse.jgit.hooks.GitHook
doRun, getErrorStream, getOutputStream, getRepository, handleError, isNativeHookPresent
-
Field Details
-
NAME
Constant indicating the name of the pre-push hook.- See Also:
-
remoteName
-
remoteLocation
-
refs
-
-
Constructor Details
-
PrePushHook
Constructor for PrePushHookThis constructor will use the default error stream.
- Parameters:
repo- The repositoryoutputStream- The output stream the hook must use.nullis allowed, in which case the hook will useSystem.out.
-
PrePushHook
Constructor for PrePushHook- Parameters:
repo- The repositoryoutputStream- The output stream the hook must use.nullis allowed, in which case the hook will useSystem.out.errorStream- The error stream the hook must use.nullis allowed, in which case the hook will useSystem.err.- Since:
- 5.6
-
-
Method Details
-
getStdinArgs
Override to provide relevant arguments via stdin to the underlying hook script. The default implementation returnsnull.- Overrides:
getStdinArgsin classGitHook<String>- Returns:
- The parameters the hook receives.
-
call
Run the hook.
- Specified by:
callin interfaceCallable<String>- Specified by:
callin classGitHook<String>- Throws:
IOExceptionAbortedByHookException
-
canRun
private boolean canRun()- Returns:
true
-
getHookName
Get name of the hook- Specified by:
getHookNamein classGitHook<String>- Returns:
- The name of the hook, which must not be
null.
-
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 two parameters, which is the name and the location of the remote repository.
- Overrides:
getParametersin classGitHook<String>- Returns:
- The parameters the hook receives.
-
setRemoteName
Set remote name- Parameters:
name- remote name
-
getRemoteName
Get remote name- Returns:
- remote name or null
- Since:
- 4.11
-
setRemoteLocation
Set remote location- Parameters:
location- a remote location
-
setRefs
Set Refs- Parameters:
toRefs- a collection ofRemoteRefUpdates
-