Package org.eclipse.jgit.api
Class PushCommand
- 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 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 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PushCommand
add(String nameOrSpec)
Add a reference to push.PushCommand
add(Ref ref)
Add a reference to push.Iterable<PushResult>
call()
Executes thepush
command with all the options and parameters collected by the setter methods of this class.ProgressMonitor
getProgressMonitor()
String
getReceivePack()
List<RefSpec>
getRefSpecs()
String
getRemote()
int
getTimeout()
boolean
isDryRun()
boolean
isForce()
boolean
isThin()
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(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
setPushTags()
Push all tags under refs/tags/*.PushCommand
setReceivePack(String receivePack)
The remote executable providing receive-pack service for pack transports.PushCommand
setRefSpecs(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(String remote)
The remote (uri or name) used for the push operation.PushCommand
setThin(boolean thin)
Sets 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
-
-
-
-
Constructor Detail
-
PushCommand
protected PushCommand(Repository repo)
- Parameters:
repo
-
-
-
Method Detail
-
call
public Iterable<PushResult> call() throws GitAPIException, InvalidRemoteException, TransportException
Executes thepush
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 interfaceCallable<Iterable<PushResult>>
- Specified by:
call
in classGitCommand<Iterable<PushResult>>
- Returns:
- an iteration over
PushResult
objects - Throws:
InvalidRemoteException
- when called with an invalid remote uriTransportException
- when an error occurs with the transportGitAPIException
-
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_NAME
will be used.- Parameters:
remote
-- Returns:
this
- See Also:
Constants.DEFAULT_REMOTE_NAME
-
getRemote
public String getRemote()
- Returns:
- the remote used for the remote operation
-
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_PACK
will be used.- Parameters:
receivePack
-- Returns:
this
- See Also:
RemoteConfig.DEFAULT_RECEIVE_PACK
-
getReceivePack
public String getReceivePack()
- Returns:
- the receive-pack used for the remote operation
-
getTimeout
public int getTimeout()
- Returns:
- the timeout used for the push operation
-
getProgressMonitor
public ProgressMonitor getProgressMonitor()
- 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
-- Returns:
this
- See Also:
NullProgressMonitor
-
setRefSpecs
public PushCommand setRefSpecs(RefSpec... specs)
The ref specs to be used in the push operation- Parameters:
specs
-- Returns:
this
-
setRefSpecs
public PushCommand setRefSpecs(List<RefSpec> specs)
The ref specs to be used in the push operation- Parameters:
specs
-- 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(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()
- 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
-- Returns:
this
-
isThin
public boolean isThin()
- Returns:
- the thin-pack preference for push operation
-
setThin
public PushCommand setThin(boolean thin)
Sets the thin-pack preference for push operation. Default setting is Transport.DEFAULT_PUSH_THIN- Parameters:
thin
-- Returns:
this
-
isForce
public boolean isForce()
- Returns:
- the force preference for push operation
-
setForce
public PushCommand setForce(boolean force)
Sets the force preference for push operation.- Parameters:
force
-- Returns:
this
-
setOutputStream
public PushCommand setOutputStream(OutputStream out)
Sets the output stream to write sideband messages to- Parameters:
out
-- Returns:
this
- Since:
- 3.0
-
-