Package org.eclipse.jgit.api
Class DeleteBranchCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<java.util.List<java.lang.String>>
-
- org.eclipse.jgit.api.DeleteBranchCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.util.List<java.lang.String>>
public class DeleteBranchCommand extends GitCommand<java.util.List<java.lang.String>>
Used to delete one or several branches. The result ofcall()is a list with the (full) names of the deleted branches. Note that we don't have a setter corresponding to the -r option; remote tracking branches are simply deleted just like local branches.- See Also:
- Git documentation about Branch
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeleteBranchCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>call()Executes the commandDeleteBranchCommandsetBranchNames(java.lang.String... branchnames)DeleteBranchCommandsetForce(boolean force)-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
DeleteBranchCommand
protected DeleteBranchCommand(Repository repo)
- Parameters:
repo-
-
-
Method Detail
-
call
public java.util.List<java.lang.String> call() throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchExceptionDescription copied from class:GitCommandExecutes the command- Specified by:
callin interfacejava.util.concurrent.Callable<java.util.List<java.lang.String>>- Specified by:
callin classGitCommand<java.util.List<java.lang.String>>- Returns:
- the list with the (full) names of the deleted branches
- Throws:
NotMergedException- when trying to delete a branch which has not been merged into the currently checked out branch without forceCannotDeleteCurrentBranchExceptionGitAPIException- or subclass thereof when an error occurs
-
setBranchNames
public DeleteBranchCommand setBranchNames(java.lang.String... branchnames)
- Parameters:
branchnames- the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored- Returns:
- this instance
-
setForce
public DeleteBranchCommand setForce(boolean force)
- Parameters:
force-truecorresponds to the -D option,falseto the -d option (default)
iffalsea check will be performed whether the branch to be deleted is already merged into the current branch and deletion will be refused in this case- Returns:
- this instance
-
-