Package org.eclipse.jgit.api
Class FetchCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<T>
-
- org.eclipse.jgit.api.TransportCommand<FetchCommand,FetchResult>
-
- org.eclipse.jgit.api.FetchCommand
-
- All Implemented Interfaces:
Callable<FetchResult>
public class FetchCommand extends TransportCommand<FetchCommand,FetchResult>
A class used to execute aFetch
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 Fetch
-
-
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
FetchCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchResult
call()
Executes thefetch
command with all the options and parameters collected by the setter methods of this class.ProgressMonitor
getProgressMonitor()
List<RefSpec>
getRefSpecs()
String
getRemote()
int
getTimeout()
boolean
isCheckFetchedObjects()
boolean
isDryRun()
boolean
isRemoveDeletedRefs()
boolean
isThin()
FetchCommand
setCheckFetchedObjects(boolean checkFetchedObjects)
If set to true, objects received will be checked for validityFetchCommand
setDryRun(boolean dryRun)
Sets whether the fetch operation should be a dry runFetchCommand
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the fetch operation.FetchCommand
setRefSpecs(List<RefSpec> specs)
The ref specs to be used in the fetch operationFetchCommand
setRefSpecs(RefSpec... specs)
The ref specs to be used in the fetch operationFetchCommand
setRemote(String remote)
The remote (uri or name) used for the fetch operation.FetchCommand
setRemoveDeletedRefs(boolean removeDeletedRefs)
If set to true, refs are removed which no longer exist in the sourceFetchCommand
setTagOpt(TagOpt tagOpt)
Sets the specification of annotated tag behavior during fetchFetchCommand
setThin(boolean thin)
Sets the thin-pack preference for fetch 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
-
FetchCommand
protected FetchCommand(Repository repo)
- Parameters:
repo
-
-
-
Method Detail
-
call
public FetchResult call() throws GitAPIException, InvalidRemoteException, TransportException
Executes thefetch
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<FetchResult>
- Specified by:
call
in classGitCommand<FetchResult>
- Returns:
- a
FetchResult
object representing the successful fetch result - Throws:
InvalidRemoteException
- when called with an invalid remote uriTransportException
- when an error occurs during transportGitAPIException
- or subclass thereof when an error occurs
-
setRemote
public FetchCommand setRemote(String remote)
The remote (uri or name) used for the fetch 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
-
getTimeout
public int getTimeout()
- Returns:
- the timeout used for the fetch operation
-
isCheckFetchedObjects
public boolean isCheckFetchedObjects()
- Returns:
- whether to check received objects checked for validity
-
setCheckFetchedObjects
public FetchCommand setCheckFetchedObjects(boolean checkFetchedObjects)
If set to true, objects received will be checked for validity- Parameters:
checkFetchedObjects
-- Returns:
this
-
isRemoveDeletedRefs
public boolean isRemoveDeletedRefs()
- Returns:
- whether or not to remove refs which no longer exist in the source
-
setRemoveDeletedRefs
public FetchCommand setRemoveDeletedRefs(boolean removeDeletedRefs)
If set to true, refs are removed which no longer exist in the source- Parameters:
removeDeletedRefs
-- Returns:
this
-
getProgressMonitor
public ProgressMonitor getProgressMonitor()
- Returns:
- the progress monitor for the fetch operation
-
setProgressMonitor
public FetchCommand setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the fetch operation. By default, this is set toNullProgressMonitor
- Parameters:
monitor
-- Returns:
this
- See Also:
NullProgressMonitor
-
setRefSpecs
public FetchCommand setRefSpecs(RefSpec... specs)
The ref specs to be used in the fetch operation- Parameters:
specs
-- Returns:
this
-
setRefSpecs
public FetchCommand setRefSpecs(List<RefSpec> specs)
The ref specs to be used in the fetch operation- Parameters:
specs
-- Returns:
this
-
isDryRun
public boolean isDryRun()
- Returns:
- the dry run preference for the fetch operation
-
setDryRun
public FetchCommand setDryRun(boolean dryRun)
Sets whether the fetch operation should be a dry run- Parameters:
dryRun
-- Returns:
this
-
isThin
public boolean isThin()
- Returns:
- the thin-pack preference for fetch operation
-
setThin
public FetchCommand setThin(boolean thin)
Sets the thin-pack preference for fetch operation. Default setting is Transport.DEFAULT_FETCH_THIN- Parameters:
thin
-- Returns:
this
-
setTagOpt
public FetchCommand setTagOpt(TagOpt tagOpt)
Sets the specification of annotated tag behavior during fetch- Parameters:
tagOpt
-- Returns:
this
-
-