Package org.eclipse.jgit.api
Class PushCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<T>
-
- org.eclipse.jgit.api.TransportCommand<PushCommand,java.lang.Iterable<PushResult>>
-
- org.eclipse.jgit.api.PushCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Iterable<PushResult>>
public class PushCommand extends TransportCommand<PushCommand,java.lang.Iterable<PushResult>>
A class used to execute aPush
command. 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 Modifier and Type Field Description private boolean
atomic
private boolean
dryRun
private boolean
force
private ProgressMonitor
monitor
private java.io.OutputStream
out
private java.util.List<java.lang.String>
pushOptions
private java.lang.String
receivePack
private java.util.Map<java.lang.String,RefLeaseSpec>
refLeaseSpecs
private java.util.List<RefSpec>
refSpecs
private java.lang.String
remote
private boolean
thin
-
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 protected
PushCommand(Repository repo)
Constructor for PushCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PushCommand
add(java.lang.String nameOrSpec)
Add a reference to push.PushCommand
add(Ref ref)
Add a reference to push.java.lang.Iterable<PushResult>
call()
ProgressMonitor
getProgressMonitor()
Get the progress monitorjava.util.List<java.lang.String>
getPushOptions()
Get push optionsjava.lang.String
getReceivePack()
Get the name of the remote executable providing the receive-pack servicejava.util.List<RefLeaseSpec>
getRefLeaseSpecs()
Get theRefLeaseSpec
s.java.util.List<RefSpec>
getRefSpecs()
GetRefSpec
s.java.lang.String
getRemote()
Get remote nameint
getTimeout()
Get timeout used for push operationboolean
isAtomic()
Whether this push should be executed atomically (all references updated, or none)boolean
isDryRun()
Whether to run the push operation as a dry runboolean
isForce()
Whether to push forcefullyboolean
isThin()
Get the thin-pack preferencePushCommand
setAtomic(boolean atomic)
Requests atomic push (all references updated, or no updates).PushCommand
setDryRun(boolean dryRun)
Sets whether the push operation should be a dry runPushCommand
setForce(boolean force)
Sets the force preference for push operation.PushCommand
setOutputStream(java.io.OutputStream out)
Sets the output stream to write sideband messages toPushCommand
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the push operation.PushCommand
setPushAll()
Push all branches under refs/heads/*.PushCommand
setPushOptions(java.util.List<java.lang.String> pushOptions)
Set the option strings associated with the push operation.PushCommand
setPushTags()
Push all tags under refs/tags/*.PushCommand
setReceivePack(java.lang.String receivePack)
The remote executable providing receive-pack service for pack transports.PushCommand
setRefLeaseSpecs(java.util.List<RefLeaseSpec> specs)
The ref lease specs to be used in the push operation, for a force-with-lease push operation.PushCommand
setRefLeaseSpecs(RefLeaseSpec... specs)
The ref lease specs to be used in the push operation, for a force-with-lease push operation.PushCommand
setRefSpecs(java.util.List<RefSpec> specs)
The ref specs to be used in the push operationPushCommand
setRefSpecs(RefSpec... specs)
The ref specs to be used in the push operationPushCommand
setRemote(java.lang.String remote)
The remote (uri or name) used for the push operation.PushCommand
setThin(boolean thin)
Set the thin-pack preference for push operation.-
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
-
-
-
-
Field Detail
-
remote
private java.lang.String remote
-
refSpecs
private final java.util.List<RefSpec> refSpecs
-
refLeaseSpecs
private final java.util.Map<java.lang.String,RefLeaseSpec> refLeaseSpecs
-
monitor
private ProgressMonitor monitor
-
receivePack
private java.lang.String receivePack
-
dryRun
private boolean dryRun
-
atomic
private boolean atomic
-
force
private boolean force
-
thin
private boolean thin
-
out
private java.io.OutputStream out
-
pushOptions
private java.util.List<java.lang.String> pushOptions
-
-
Constructor Detail
-
PushCommand
protected PushCommand(Repository repo)
Constructor for PushCommand.
- Parameters:
repo
- theRepository
-
-
Method Detail
-
call
public java.lang.Iterable<PushResult> call() throws GitAPIException, InvalidRemoteException, TransportException
Execute the command
Execute the
push
command 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:
call
in interfacejava.util.concurrent.Callable<java.lang.Iterable<PushResult>>
- Specified by:
call
in classGitCommand<java.lang.Iterable<PushResult>>
- Throws:
GitAPIException
InvalidRemoteException
TransportException
-
setRemote
public PushCommand setRemote(java.lang.String remote)
The remote (uri or name) used for the push operation. If no remote is set, the default value ofConstants.DEFAULT_REMOTE_NAME
will be used.- Parameters:
remote
- the remote name- Returns:
this
- See Also:
Constants.DEFAULT_REMOTE_NAME
-
getRemote
public java.lang.String getRemote()
Get remote name- Returns:
- the remote used for the remote operation
-
setReceivePack
public PushCommand setReceivePack(java.lang.String receivePack)
The remote executable providing receive-pack service for pack transports. If no receive-pack is set, the default value ofRemoteConfig.DEFAULT_RECEIVE_PACK
will be used.- Parameters:
receivePack
- name of the remote executable providing the receive-pack service- Returns:
this
- See Also:
RemoteConfig.DEFAULT_RECEIVE_PACK
-
getReceivePack
public java.lang.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 java.util.List<RefLeaseSpec> getRefLeaseSpecs()
Get theRefLeaseSpec
s.- Returns:
- the
RefLeaseSpec
s - 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
- aRefLeaseSpec
object.- Returns:
this
- Since:
- 4.7
-
setRefLeaseSpecs
public PushCommand setRefLeaseSpecs(java.util.List<RefLeaseSpec> specs)
The ref lease specs to be used in the push operation, for a force-with-lease push operation.- Parameters:
specs
- list ofRefLeaseSpec
s- Returns:
this
- Since:
- 4.7
-
getRefSpecs
public java.util.List<RefSpec> getRefSpecs()
GetRefSpec
s.- Returns:
- the ref specs
-
setRefSpecs
public PushCommand setRefSpecs(RefSpec... specs)
The ref specs to be used in the push operation- Parameters:
specs
- aRefSpec
object.- Returns:
this
-
setRefSpecs
public PushCommand setRefSpecs(java.util.List<RefSpec> specs)
The ref specs to be used in the push operation- Parameters:
specs
- list ofRefSpec
s- Returns:
this
-
setPushAll
public PushCommand setPushAll()
Push all branches under refs/heads/*.- Returns:
- {code this}
-
setPushTags
public PushCommand setPushTags()
Push all tags under refs/tags/*.- Returns:
- {code 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(java.lang.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
-
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(java.io.OutputStream out)
Sets the output stream to write sideband messages to- Parameters:
out
- anOutputStream
- Returns:
this
- Since:
- 3.0
-
getPushOptions
public java.util.List<java.lang.String> getPushOptions()
Get push options- Returns:
- the option strings associated with the push operation
- Since:
- 4.5
-
setPushOptions
public PushCommand setPushOptions(java.util.List<java.lang.String> pushOptions)
Set the option strings associated with the push operation.- Parameters:
pushOptions
- aList
of push option strings- Returns:
this
- Since:
- 4.5
-
-