- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<T>
-
- org.eclipse.jgit.api.TransportCommand<PushCommand,Iterable<PushResult>>
-
- org.eclipse.jgit.api.PushCommand
-
- All Implemented Interfaces:
Callable<Iterable<PushResult>>
public class PushCommand extends TransportCommand<PushCommand,Iterable<PushResult>>
A class used to execute aPushcommand. It has setters for all supported options and arguments of this command and acall()method to finally execute the command.- See Also:
- Git documentation about Push
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.TransportCommand
credentialsProvider, timeout, transportConfigCallback
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPushCommand(Repository repo)Constructor for PushCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PushCommandadd(String nameOrSpec)Add a reference to push.PushCommandadd(Ref ref)Add a reference to push.Iterable<PushResult>call()ProgressMonitorgetProgressMonitor()Get the progress monitorPushConfig.PushDefaultgetPushDefault()Retrieves thePushConfig.PushDefaultcurrently set.List<String>getPushOptions()Get push optionsStringgetReceivePack()Get the name of the remote executable providing the receive-pack serviceList<RefLeaseSpec>getRefLeaseSpecs()Get theRefLeaseSpecs.List<RefSpec>getRefSpecs()GetRefSpecs.StringgetRemote()Get remote nameintgetTimeout()Get timeout used for push operationbooleanisAtomic()Whether this push should be executed atomically (all references updated, or none)booleanisDryRun()Whether to run the push operation as a dry runbooleanisForce()Whether to push forcefullybooleanisThin()Get the thin-pack preferencebooleanisUseBitmaps()Whether to use bitmaps for push.PushCommandsetAtomic(boolean atomic)Requests atomic push (all references updated, or no updates).PushCommandsetDryRun(boolean dryRun)Sets whether the push operation should be a dry runPushCommandsetForce(boolean force)Sets the force preference for push operation.PushCommandsetHookErrorStream(PrintStream redirect)Sets aPrintStreama "pre-push" hook may write its stderr to.PushCommandsetHookOutputStream(PrintStream redirect)Sets aPrintStreama "pre-push" hook may write its stdout to.PushCommandsetOutputStream(OutputStream out)Sets the output stream to write sideband messages toPushCommandsetProgressMonitor(ProgressMonitor monitor)The progress monitor associated with the push operation.PushCommandsetPushAll()Push all branches under refs/heads/*.PushCommandsetPushDefault(PushConfig.PushDefault pushDefault)Sets an explicitPushConfig.PushDefault.PushCommandsetPushOptions(List<String> pushOptions)Set the option strings associated with the push operation.PushCommandsetPushTags()Push all tags under refs/tags/*.PushCommandsetReceivePack(String receivePack)The remote executable providing receive-pack service for pack transports.PushCommandsetRefLeaseSpecs(List<RefLeaseSpec> specs)The ref lease specs to be used in the push operation, for a force-with-lease push operation.PushCommandsetRefLeaseSpecs(RefLeaseSpec... specs)The ref lease specs to be used in the push operation, for a force-with-lease push operation.PushCommandsetRefSpecs(List<RefSpec> specs)The ref specs to be used in the push operationPushCommandsetRefSpecs(RefSpec... specs)The ref specs to be used in the push operationPushCommandsetRemote(String remote)The remote (uri or name) used for the push operation.PushCommandsetThin(boolean thin)Set the thin-pack preference for push operation.PushCommandsetUseBitmaps(boolean useBitmaps)Set whether to use bitmaps for push.-
Methods inherited from class org.eclipse.jgit.api.TransportCommand
configure, configure, self, setCredentialsProvider, setTimeout, setTransportConfigCallback
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
PushCommand
protected PushCommand(Repository repo)
Constructor for PushCommand.
- Parameters:
repo- theRepository
-
-
Method Detail
-
call
public Iterable<PushResult> call() throws GitAPIException, InvalidRemoteException, TransportException
Execute the command
Execute the
pushcommand with all the options and parameters collected by the setter methods of this class. Each instance of this class should only be used for one invocation of the command (means: one call tocall())- Specified by:
callin interfaceCallable<Iterable<PushResult>>- Specified by:
callin classGitCommand<Iterable<PushResult>>- Throws:
GitAPIExceptionInvalidRemoteExceptionTransportException
-
setRemote
public PushCommand setRemote(String remote)
The remote (uri or name) used for the push operation. If no remote is set, the default value ofConstants.DEFAULT_REMOTE_NAMEwill be used.- Parameters:
remote- the remote name- Returns:
this- See Also:
Constants.DEFAULT_REMOTE_NAME
-
getRemote
public String getRemote()
Get remote name- Returns:
- the remote used for the remote operation
-
setHookOutputStream
public PushCommand setHookOutputStream(PrintStream redirect)
Sets aPrintStreama "pre-push" hook may write its stdout to. If not set,System.outwill be used.When pushing to several remote repositories the stream is shared for all pushes.
- Parameters:
redirect-PrintStreamto use; ifnull,System.outwill be used- Returns:
this- Since:
- 6.4
-
setHookErrorStream
public PushCommand setHookErrorStream(PrintStream redirect)
Sets aPrintStreama "pre-push" hook may write its stderr to. If not set,System.errwill be used.When pushing to several remote repositories the stream is shared for all pushes.
- Parameters:
redirect-PrintStreamto use; ifnull,System.errwill be used- Returns:
this- Since:
- 6.4
-
setReceivePack
public PushCommand setReceivePack(String receivePack)
The remote executable providing receive-pack service for pack transports. If no receive-pack is set, the default value ofRemoteConfig.DEFAULT_RECEIVE_PACKwill be used.- Parameters:
receivePack- name of the remote executable providing the receive-pack service- Returns:
this- See Also:
RemoteConfig.DEFAULT_RECEIVE_PACK
-
getReceivePack
public String getReceivePack()
Get the name of the remote executable providing the receive-pack service- Returns:
- the receive-pack used for the remote operation
-
getTimeout
public int getTimeout()
Get timeout used for push operation- Returns:
- the timeout used for the push operation
-
getProgressMonitor
public ProgressMonitor getProgressMonitor()
Get the progress monitor- Returns:
- the progress monitor for the push operation
-
setProgressMonitor
public PushCommand setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the push operation. By default, this is set toNullProgressMonitor- Parameters:
monitor- aProgressMonitor- Returns:
this- See Also:
NullProgressMonitor
-
getRefLeaseSpecs
public List<RefLeaseSpec> getRefLeaseSpecs()
Get theRefLeaseSpecs.- Returns:
- the
RefLeaseSpecs - Since:
- 4.7
-
setRefLeaseSpecs
public PushCommand setRefLeaseSpecs(RefLeaseSpec... specs)
The ref lease specs to be used in the push operation, for a force-with-lease push operation.- Parameters:
specs- aRefLeaseSpecobject.- Returns:
this- Since:
- 4.7
-
setRefLeaseSpecs
public PushCommand setRefLeaseSpecs(List<RefLeaseSpec> specs)
The ref lease specs to be used in the push operation, for a force-with-lease push operation.- Parameters:
specs- list ofRefLeaseSpecs- Returns:
this- Since:
- 4.7
-
setRefSpecs
public PushCommand setRefSpecs(RefSpec... specs)
The ref specs to be used in the push operation- Parameters:
specs- aRefSpecobject.- Returns:
this
-
setRefSpecs
public PushCommand setRefSpecs(List<RefSpec> specs)
The ref specs to be used in the push operation- Parameters:
specs- list ofRefSpecs- Returns:
this
-
getPushDefault
public PushConfig.PushDefault getPushDefault()
Retrieves thePushConfig.PushDefaultcurrently set.- Returns:
- the
PushConfig.PushDefault, ornullif not set - Since:
- 6.1
-
setPushDefault
public PushCommand setPushDefault(PushConfig.PushDefault pushDefault)
Sets an explicitPushConfig.PushDefault. The default used if this is not called isPushConfig.PushDefault.CURRENTfor compatibility reasons with earlier JGit versions.- Parameters:
pushDefault-PushConfig.PushDefaultto set; ifnullthe value defined in the git config will be used.- Returns:
this- Since:
- 6.1
-
setPushAll
public PushCommand setPushAll()
Push all branches under refs/heads/*.- Returns:
this
-
setPushTags
public PushCommand setPushTags()
Push all tags under refs/tags/*.- Returns:
this
-
add
public PushCommand add(Ref ref)
Add a reference to push.- Parameters:
ref- the source reference. The remote name will match.- Returns:
this.
-
add
public PushCommand add(String nameOrSpec)
Add a reference to push.- Parameters:
nameOrSpec- any reference name, or a reference specification.- Returns:
this.- Throws:
JGitInternalException- the reference name cannot be resolved.
-
isDryRun
public boolean isDryRun()
Whether to run the push operation as a dry run- Returns:
- the dry run preference for the push operation
-
setDryRun
public PushCommand setDryRun(boolean dryRun)
Sets whether the push operation should be a dry run- Parameters:
dryRun- a boolean.- Returns:
this
-
isThin
public boolean isThin()
Get the thin-pack preference- Returns:
- the thin-pack preference for push operation
-
setThin
public PushCommand setThin(boolean thin)
Set the thin-pack preference for push operation. Default setting is Transport.DEFAULT_PUSH_THIN- Parameters:
thin- the thin-pack preference value- Returns:
this
-
isUseBitmaps
public boolean isUseBitmaps()
Whether to use bitmaps for push.- Returns:
- true if push use bitmaps.
- Since:
- 6.4
-
setUseBitmaps
public PushCommand setUseBitmaps(boolean useBitmaps)
Set whether to use bitmaps for push. Default setting is true- Parameters:
useBitmaps- false to disable use of bitmaps for push, true otherwise.- Returns:
this- Since:
- 6.4
-
isAtomic
public boolean isAtomic()
Whether this push should be executed atomically (all references updated, or none)- Returns:
- true if all-or-nothing behavior is requested.
- Since:
- 4.2
-
setAtomic
public PushCommand setAtomic(boolean atomic)
Requests atomic push (all references updated, or no updates). Default setting is false.- Parameters:
atomic- whether to run the push atomically- Returns:
this- Since:
- 4.2
-
isForce
public boolean isForce()
Whether to push forcefully- Returns:
- the force preference for push operation
-
setForce
public PushCommand setForce(boolean force)
Sets the force preference for push operation.- Parameters:
force- whether to push forcefully- Returns:
this
-
setOutputStream
public PushCommand setOutputStream(OutputStream out)
Sets the output stream to write sideband messages to- Parameters:
out- anOutputStream- Returns:
this- Since:
- 3.0
-
getPushOptions
public List<String> getPushOptions()
Get push options- Returns:
- the option strings associated with the push operation
- Since:
- 4.5
-
setPushOptions
public PushCommand setPushOptions(List<String> pushOptions)
Set the option strings associated with the push operation.- Parameters:
pushOptions- aListof push option strings- Returns:
this- Since:
- 4.5
-
-