Package org.eclipse.jgit.api
Class FetchCommand
- All Implemented Interfaces:
Callable<FetchResult>
A class used to execute a
Fetch
command. It has setters for all
supported options and arguments of this command and a call()
method
to finally execute the command.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback for status of fetch operation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FetchCommand.Callback
private boolean
private boolean
private String
private boolean
private ProgressMonitor
private String
private Boolean
private TagOpt
private boolean
Fields inherited from class org.eclipse.jgit.api.TransportCommand
credentialsProvider, timeout, transportConfigCallback
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FetchCommand
(Repository repo) Constructor for FetchCommand. -
Method Summary
Modifier and TypeMethodDescriptionapplyOptions
(List<RefSpec> refSpecs2) call()
private void
fetchSubmodules
(FetchResult results) Get progress monitorgetRecurseMode
(String path) Get list ofRefSpec
sGet the remoteint
Get timeoutboolean
Whether to check received objects for validityboolean
isDryRun()
Whether to do a dry runboolean
Whether fetch --force option is enabledboolean
Whether to remove refs which no longer exist in the sourceboolean
isThin()
Get thin-pack preferencesetCallback
(FetchCommand.Callback callback) Register a progress callback.setCheckFetchedObjects
(boolean checkFetchedObjects) If set totrue
, objects received will be checked for validitysetDryRun
(boolean dryRun) Sets whether the fetch operation should be a dry runsetForceUpdate
(boolean force) Set fetch --force optionsetInitialBranch
(String branch) Set the initial branchsetProgressMonitor
(ProgressMonitor monitor) The progress monitor associated with the fetch operation.Set the mode to be used for recursing into submodules.setRefSpecs
(String... specs) The ref specs to be used in the fetch operationsetRefSpecs
(List<RefSpec> specs) The ref specs to be used in the fetch operationsetRefSpecs
(RefSpec... specs) The ref specs to be used in the fetch operationThe remote (uri or name) used for the fetch operation.setRemoveDeletedRefs
(boolean removeDeletedRefs) If set totrue
, refs are removed which no longer exist in the sourceSets the specification of annotated tag behavior during fetchsetThin
(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
-
Field Details
-
remote
-
refSpecs
-
monitor
-
checkFetchedObjects
private boolean checkFetchedObjects -
removeDeletedRefs
-
dryRun
private boolean dryRun -
thin
private boolean thin -
tagOption
-
submoduleRecurseMode
-
callback
-
isForceUpdate
private boolean isForceUpdate -
initialBranch
-
-
Constructor Details
-
FetchCommand
Constructor for FetchCommand.- Parameters:
repo
- aRepository
object.
-
-
Method Details
-
getRecurseMode
-
fetchSubmodules
private void fetchSubmodules(FetchResult results) throws TransportException, GitAPIException, InvalidConfigurationException -
call
Execute the command
Execute the
fetch
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>
- Throws:
GitAPIException
InvalidRemoteException
TransportException
-
applyOptions
-
setRecurseSubmodules
public FetchCommand setRecurseSubmodules(@Nullable SubmoduleConfig.FetchRecurseSubmodulesMode recurse) Set the mode to be used for recursing into submodules.- Parameters:
recurse
- corresponds to the --recurse-submodules/--no-recurse-submodules options. Ifnull
use the value of thesubmodule.name.fetchRecurseSubmodules
option configured per submodule. If not specified there, use the value of thefetch.recurseSubmodules
option configured in git config. If not configured in either, "on-demand" is the built-in default.- Returns:
this
- Since:
- 4.7
-
setRemote
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
- name of a remote- Returns:
this
- See Also:
-
getRemote
Get the remote- Returns:
- the remote used for the remote operation
-
getTimeout
public int getTimeout()Get timeout- Returns:
- the timeout used for the fetch operation
-
isCheckFetchedObjects
public boolean isCheckFetchedObjects()Whether to check received objects for validity- Returns:
- whether to check received objects for validity
-
setCheckFetchedObjects
If set totrue
, objects received will be checked for validity- Parameters:
checkFetchedObjects
- whether to check objects for validity- Returns:
this
-
isRemoveDeletedRefs
public boolean isRemoveDeletedRefs()Whether to remove refs which no longer exist in the source- Returns:
- whether to remove refs which no longer exist in the source
-
setRemoveDeletedRefs
If set totrue
, refs are removed which no longer exist in the source- Parameters:
removeDeletedRefs
- whether to remove deletedRef
s- Returns:
this
-
getProgressMonitor
Get progress monitor- Returns:
- the progress monitor for the fetch operation
-
setProgressMonitor
The progress monitor associated with the fetch operation. By default, this is set toNullProgressMonitor
- Parameters:
monitor
- aProgressMonitor
- Returns:
this
- See Also:
-
getRefSpecs
Get list ofRefSpec
s- Returns:
- the ref specs
-
setRefSpecs
The ref specs to be used in the fetch operation- Parameters:
specs
- String representation ofRefSpec
s- Returns:
this
- Since:
- 4.9
-
setRefSpecs
The ref specs to be used in the fetch operation- Parameters:
specs
- one or multipleRefSpec
s- Returns:
this
-
setRefSpecs
The ref specs to be used in the fetch operation- Parameters:
specs
- list ofRefSpec
s- Returns:
this
-
isDryRun
public boolean isDryRun()Whether to do a dry run- Returns:
- the dry run preference for the fetch operation
-
setDryRun
Sets whether the fetch operation should be a dry run- Parameters:
dryRun
- whether to do a dry run- Returns:
this
-
isThin
public boolean isThin()Get thin-pack preference- Returns:
- the thin-pack preference for fetch operation
-
setThin
Sets the thin-pack preference for fetch operation. Default setting is Transport.DEFAULT_FETCH_THIN- Parameters:
thin
- the thin-pack preference- Returns:
this
-
setTagOpt
Sets the specification of annotated tag behavior during fetch- Parameters:
tagOpt
- theTagOpt
- Returns:
this
-
setInitialBranch
Set the initial branch- Parameters:
branch
- the initial branch to check out when cloning the repository. Can be specified as ref name (refs/heads/master
), branch name (master
) or tag name (v1.2.3
). The default is to use the branch pointed to by the cloned repository's HEAD and can be requested by passingnull
orHEAD
.- Returns:
this
- Since:
- 5.11
-
setCallback
Register a progress callback.- Parameters:
callback
- the callback- Returns:
this
- Since:
- 4.8
-
isForceUpdate
public boolean isForceUpdate()Whether fetch --force option is enabled- Returns:
- whether refs affected by the fetch are updated forcefully
- Since:
- 5.0
-
setForceUpdate
Set fetch --force option- Parameters:
force
- whether to update refs affected by the fetch forcefully- Returns:
- this command
- Since:
- 5.0
-