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 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)
-
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()Executes thepushcommand with all the options and parameters collected by the setter methods of this class.ProgressMonitorgetProgressMonitor()StringgetReceivePack()List<RefSpec>getRefSpecs()StringgetRemote()intgetTimeout()booleanisDryRun()booleanisForce()booleanisThin()PushCommandsetDryRun(boolean dryRun)Sets whether the push operation should be a dry runPushCommandsetForce(boolean force)Sets the force preference for push operation.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/*.PushCommandsetPushTags()Push all tags under refs/tags/*.PushCommandsetReceivePack(String receivePack)The remote executable providing receive-pack service for pack transports.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)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 thepushcommand 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>>- Returns:
- an iteration over
PushResultobjects - 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_NAMEwill 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_PACKwill 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
-
-