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
ConstructorsModifierConstructorDescriptionprotected
PrePushHook
(Repository repo, PrintStream outputStream) Constructor for PrePushHookprotected
PrePushHook
(Repository repo, PrintStream outputStream, PrintStream errorStream) Constructor for PrePushHook -
Method Summary
Modifier and TypeMethodDescriptioncall()
private boolean
canRun()
Get name of the hookprotected String[]
Override this method when needed to provide relevant parameters to the underlying hook script.protected String
Get remote nameprotected String
Override to provide relevant arguments via stdin to the underlying hook script.void
setRefs
(Collection<RemoteRefUpdate> toRefs) Set Refsvoid
setRemoteLocation
(String location) Set remote locationvoid
setRemoteName
(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.null
is allowed, in which case the hook will useSystem.out
.
-
PrePushHook
Constructor for PrePushHook- Parameters:
repo
- The repositoryoutputStream
- The output stream the hook must use.null
is allowed, in which case the hook will useSystem.out
.errorStream
- The error stream the hook must use.null
is 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:
getStdinArgs
in classGitHook<String>
- Returns:
- The parameters the hook receives.
-
call
Run the hook.
- Specified by:
call
in interfaceCallable<String>
- Specified by:
call
in classGitHook<String>
- Throws:
IOException
AbortedByHookException
-
canRun
private boolean canRun()- Returns:
true
-
getHookName
Get name of the hook- Specified by:
getHookName
in 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:
getParameters
in 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 ofRemoteRefUpdate
s
-