- java.lang.Object
-
- org.eclipse.jgit.hooks.GitHook<String>
-
- org.eclipse.jgit.hooks.PrePushHook
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPrePushHook(Repository repo, PrintStream outputStream)Constructor for PrePushHookprotectedPrePushHook(Repository repo, PrintStream outputStream, PrintStream errorStream)Constructor for PrePushHook
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcall()StringgetHookName()Get name of the hookprotected String[]getParameters()Override this method when needed to provide relevant parameters to the underlying hook script.protected StringgetRemoteName()Get remote nameprotected StringgetStdinArgs()Override to provide relevant arguments via stdin to the underlying hook script.protected booleanisDryRun()Tells whether the push is a dry run.voidsetDryRun(boolean dryRun)Sets whether the push is a dry run.voidsetRefs(Collection<RemoteRefUpdate> toRefs)Set RefsvoidsetRemoteLocation(String location)Set remote locationvoidsetRemoteName(String name)Set remote name-
Methods inherited from class org.eclipse.jgit.hooks.GitHook
doRun, getErrorStream, getOutputStream, getRepository, handleError, isNativeHookPresent
-
-
-
-
Field Detail
-
NAME
public static final String NAME
Constant indicating the name of the pre-push hook.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PrePushHook
protected PrePushHook(Repository repo, PrintStream outputStream)
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
protected PrePushHook(Repository repo, PrintStream outputStream, PrintStream errorStream)
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 Detail
-
getStdinArgs
protected String 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
public String call() throws IOException, AbortedByHookException
Run the hook.
- Specified by:
callin interfaceCallable<String>- Specified by:
callin classGitHook<String>- Throws:
IOExceptionAbortedByHookException
-
getHookName
public String getHookName()
Get name of the hook- Specified by:
getHookNamein classGitHook<String>- Returns:
- The name of the hook, which must not be
null.
-
getParameters
protected String[] 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
public void setRemoteName(String name)
Set remote name- Parameters:
name- remote name
-
getRemoteName
protected String getRemoteName()
Get remote name- Returns:
- remote name or null
- Since:
- 4.11
-
setRemoteLocation
public void setRemoteLocation(String location)
Set remote location- Parameters:
location- a remote location
-
setDryRun
public void setDryRun(boolean dryRun)
Sets whether the push is a dry run.- Parameters:
dryRun-trueif the push is a dry run,falseotherwise- Since:
- 6.2
-
isDryRun
protected boolean isDryRun()
Tells whether the push is a dry run.- Returns:
trueif the push is a dry run,falseotherwise- Since:
- 6.2
-
setRefs
public void setRefs(Collection<RemoteRefUpdate> toRefs)
Set Refs- Parameters:
toRefs- a collection ofRemoteRefUpdates
-
-