void deleteBranch(String branchName) throws GitAPIException { try { git.branchDelete().setBranchNames(branchName).setForce(true).call(); } catch (GitAPIException e) { LOGGER.error("[CONFIG_MERGE] Failed to delete branch {}", branchName, e); throw e; } }
/** * Return a command object used to delete branches * * @return a {@link org.eclipse.jgit.api.DeleteBranchCommand} */ public DeleteBranchCommand branchDelete() { return new DeleteBranchCommand(repo); }
/** * Set whether to forcefully delete branches * * @param force * <code>true</code> corresponds to the -D option, * <code>false</code> to the -d option (default) <br> * if <code>false</code> a 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 * @return this instance */ public DeleteBranchCommand setForce(boolean force) { checkCallable(); this.force = force; return this; } }
@Signature public List<String> branchDelete(String[] names, boolean force) throws GitAPIException { DeleteBranchCommand command = getWrappedObject().branchDelete(); command.setBranchNames(names); return command.call(); }
public List<String> call() throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchException { checkCallable(); List<String> result = new ArrayList<>(); if (branchNames.isEmpty()) setCallable(false); for (String branchName : branchNames) { if (branchName == null)
protected void doDeleteBranch(Exchange exchange, String operation) throws Exception { if (ObjectHelper.isEmpty(endpoint.getBranchName())) { throw new IllegalArgumentException("Branch Name must be specified to execute " + operation); } try { git.branchDelete().setBranchNames(endpoint.getBranchName()).call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } }
checkCallable(); List<String> result = new ArrayList<String>(); if (branchNames.isEmpty()) setCallable(false); for (String branchName : branchNames) { if (branchName == null)
private List<String> deleteBranches(Git git, Collection<String> branchesToDelete) throws GitAPIException { DeleteBranchCommand deleteBranchCommand = git.branchDelete() .setBranchNames(branchesToDelete.toArray(new String[0])) //local branch can contain data which is not merged to HEAD - force delete it anyway, since local copy should be R/O .setForce(true); List<String> resultList = deleteBranchCommand.call(); logger.info(format("Deleted %s branches from %s branches to delete.", resultList, branchesToDelete)); return resultList; }
public void deleteBranch(String name) throws GitException { verifyGitRepository(); try { jGitDelegate.branchDelete().setBranchNames(name).call(); } catch (GitAPIException e) { throw new GitException(Messages.GitAPI_Branch_DeleteErrorMsg(name), e); } }
public List<String> call() throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchException { checkCallable(); List<String> result = new ArrayList<>(); if (branchNames.isEmpty()) setCallable(false); for (String branchName : branchNames) { if (branchName == null)
/** * Set the names of the branches to delete * * @param branchnames * the names of the branches to delete; if not set, this will do * nothing; invalid branch names will simply be ignored * @return this instance */ public DeleteBranchCommand setBranchNames(String... branchnames) { checkCallable(); this.branchNames.clear(); for (String branch : branchnames) this.branchNames.add(branch); return this; }
/** * Returns a command object used to delete branches * * @return a {@link DeleteBranchCommand} */ public DeleteBranchCommand branchDelete() { return new DeleteBranchCommand(repo); }
System.out.println("Removing branch before"); git.branchDelete() .setBranchNames("testbranch") .setForce(true) .call(); .setBranchNames("testbranch") .call();
/** * @param force * <code>true</code> corresponds to the -D option, * <code>false</code> to the -d option (default) <br> * if <code>false</code> a 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 * @return this instance */ public DeleteBranchCommand setForce(boolean force) { checkCallable(); this.force = force; return this; } }
/** * Return a command object used to delete branches * * @return a {@link org.eclipse.jgit.api.DeleteBranchCommand} */ public DeleteBranchCommand branchDelete() { return new DeleteBranchCommand(repo); }
System.out.println("Removing branch before"); git.branchDelete() .setBranchNames("testbranch") .setForce(true) .call(); .setBranchNames("testbranch") .call();
/** * Set whether to forcefully delete branches * * @param force * <code>true</code> corresponds to the -D option, * <code>false</code> to the -d option (default) <br> * if <code>false</code> a 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 * @return this instance */ public DeleteBranchCommand setForce(boolean force) { checkCallable(); this.force = force; return this; } }
public void deleteLocalBranch(String branchName) throws Exception { git.branchDelete().setForce(true).setBranchNames(branchName).call(); }
/** * @param branchnames * the names of the branches to delete; if not set, this will do * nothing; invalid branch names will simply be ignored * @return this instance */ public DeleteBranchCommand setBranchNames(String... branchnames) { checkCallable(); this.branchNames.clear(); for (String branch : branchnames) this.branchNames.add(branch); return this; }
/** * Delete branch * @param git * @throws GitAPIException */ private void deleteTempBranch(Git git, String branchName) throws Exception { try { git.branchDelete() .setForce(true) .setBranchNames(branchName) .call(); } catch (GitAPIException e) { throw new Exception(DELETING_BRANCH_REASON, e); } }