Package org.eclipse.jgit.api
Class CleanCommand
Remove untracked files from the working tree
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate booleanFields inherited from class org.eclipse.jgit.api.GitCommand
repo -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCleanCommand(Repository repo) Constructor for CleanCommand -
Method Summary
Modifier and TypeMethodDescriptioncall()When dryRun is false, deletes the specified path from disk.filterFolders(Set<String> untracked, Set<String> untrackedFolders) filterIgnorePaths(Set<String> inputPaths, Set<String> ignoredNotInIndex, boolean exact) setCleanDirectories(boolean dirs) If dirs is set, in addition to files, also clean directories.setDryRun(boolean dryRun) If dryRun is set, the paths in question will not actually be deleted.setForce(boolean force) If force is set, directories that are git repositories will also be deleted.setIgnore(boolean ignore) If ignore is set, don't report/clean files/directories that are ignored by a .gitignore.If paths are set, only these paths are affected by the cleaning.Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
paths
-
dryRun
private boolean dryRun -
directories
private boolean directories -
ignore
private boolean ignore -
force
private boolean force
-
-
Constructor Details
-
CleanCommand
Constructor for CleanCommand- Parameters:
repo- theRepository
-
-
Method Details
-
call
Execute the command
Executes the
cleancommand 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<Set<String>>- Specified by:
callin classGitCommand<Set<String>>- Throws:
NoWorkTreeExceptionGitAPIException
-
cleanPath
When dryRun is false, deletes the specified path from disk. If dryRun is true, no paths are actually deleted. In both cases, the paths that would have been deleted are added to inFiles and returned. Paths that are directories are recursively deleted whendirectoriesis true. Paths that are git repositories are recursively deleted whendirectoriesandforceare both true.- Parameters:
path- The path to be cleanedinFiles- A set of strings representing the files that have been cleaned already, the path to be cleaned will be added to this set before being returned.- Returns:
- a set of strings with the cleaned path added to it
- Throws:
IOException
-
filterIgnorePaths
-
filterFolders
-
setPaths
If paths are set, only these paths are affected by the cleaning.- Parameters:
paths- the paths to set (with/as separator)- Returns:
this
-
setDryRun
If dryRun is set, the paths in question will not actually be deleted.- Parameters:
dryRun- whether to do a dry run or not- Returns:
this
-
setForce
If force is set, directories that are git repositories will also be deleted.- Parameters:
force- whether or not to delete git repositories- Returns:
this- Since:
- 4.5
-
setCleanDirectories
If dirs is set, in addition to files, also clean directories.- Parameters:
dirs- whether to clean directories too, or only files.- Returns:
this
-
setIgnore
If ignore is set, don't report/clean files/directories that are ignored by a .gitignore. otherwise do handle them.- Parameters:
ignore- whether to respect .gitignore or not.- Returns:
this
-