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; } }
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; }
@Signature public List<String> branchDelete(String[] names, boolean force) throws GitAPIException { DeleteBranchCommand command = getWrappedObject().branchDelete(); command.setBranchNames(names); return command.call(); }
System.out.println("Removing branch before"); git.branchDelete() .setBranchNames("testbranch") .setForce(true) .call(); .setBranchNames("testbranch") .call();
System.out.println("Removing branch before"); git.branchDelete() .setBranchNames("testbranch") .setForce(true) .call(); .setBranchNames("testbranch") .call();
private void deleteUnfilteredBranches(Repository repository) throws GitAPIException { final org.eclipse.jgit.api.Git git = org.eclipse.jgit.api.Git.wrap(repository); final String[] toDelete = git.branchList() .call() .stream() .map(ref -> ref.getName()) .map(fullname -> fullname.substring(fullname.lastIndexOf('/') + 1)) .filter(name -> !branches.contains(name)) .toArray(String[]::new); git.branchDelete() .setBranchNames(toDelete) .setForce(true) .call(); }
public void deleteBranch(boolean force, String... branchesToDelete) { DeleteBranchCommand branchDelete = _git.branchDelete(); branchDelete.setForce(force); try { List<String> call = branchDelete.setBranchNames(branchesToDelete).call(); call.toString(); for (String currBranch : branchesToDelete) { push(null, REFS_HEADS + currBranch); } } catch (Throwable e) { throw new RuntimeException(String.format( "Failed to delete branches [%s]", Arrays.toString(branchesToDelete)), e); } }
/** * 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); } }
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; } }
public void deleteLocalBranch(String branchName) throws Exception { git.branchDelete().setForce(true).setBranchNames(branchName).call(); }
public static boolean removeBranch(Git git, String branch) throws GitAPIException { IllegalStateAssertion.assertFalse("master".equals(branch), "Cannot remove master branch"); if (localBranchExists(git, branch)) { String current = currentBranch(git); if (equals(current, branch)) { checkoutBranch(git, "master"); } List<String> list = git.branchDelete().setBranchNames(branch).setForce(true).call(); LOGGER.debug("Deleted branch {} with results: {}", branch, list); return true; } else { LOGGER.debug("Branch {} not found!", branch); return true; } }
private synchronized void deleteMMBranch(Git git) throws GitAPIException { List<Ref> refs = git.branchList().call(); for (Ref r : refs) { if (r.getName().endsWith(BRANCH_MM)) { git.branchDelete().setBranchNames(BRANCH_MM).setForce(true).call(); break; } } }
public static boolean removeBranch(Git git, String branch) throws GitAPIException { IllegalStateAssertion.assertFalse("master".equals(branch), "Cannot remove master branch"); if (localBranchExists(git, branch)) { String current = currentBranch(git); if (equals(current, branch)) { checkoutBranch(git, "master"); } List<String> list = git.branchDelete().setBranchNames(branch).setForce(true).call(); LOGGER.debug("Deleted branch {} with results: {}", branch, list); return true; } else { LOGGER.debug("Branch {} not found!", branch); return true; } }
public static void deleteBranch(final Git git, final Ref branch) { try { git.branchDelete().setBranchNames(branch.getName()).setForce(true).call(); } catch (final GitAPIException e) { throw new IOException(e); } }
public static void deleteBranch( final Git git, final Ref branch ) { try { git.branchDelete().setBranchNames( branch.getName() ).setForce( true ).call(); } catch ( final GitAPIException e ) { throw new IOException( e ); } }
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 void execute() { try { git._branchDelete().setBranchNames(branch.getName()).setForce(true).call(); } catch (final GitAPIException e) { throw new IOException(e); } } }
public synchronized void reset() { try (Git git = openRepository()) { git.checkout().setName(mainBranchName).setForce(true).call(); git.branchDelete().setBranchNames(BRANCH_MM).setForce(true).call(); } catch (Exception e) { throw new RuntimeException(e); } }
/** {@inheritDoc} */ @Override public void deleteBranch(String name) throws GitException { try (Repository repo = getRepository()) { git(repo).branchDelete().setForce(true).setBranchNames(name).call(); } catch (GitAPIException e) { throw new GitException(e); } }
@Override public void close() throws Exception { shutdown(0); if (safeBranch) { new Git(repository) .branchDelete() .setBranchNames(testBranch) .setForce(true) .call(); } for (SvnOperationFactory factory : svnFactories) { factory.dispose(); } svnFactories.clear(); repository.close(); TestHelper.deleteDirectory(tempDirectory); }