List of usage examples for org.eclipse.jgit.api DeleteBranchCommand setForce
public DeleteBranchCommand setForce(boolean force)
From source file:com.tasktop.c2c.server.scm.service.GitServiceBean.java
License:Open Source License
@Secured({ Role.User }) @Override//from ww w . j a v a 2 s . c o m public void deleteBranch(String repoName, String branchName) throws EntityNotFoundException { try { Repository r = findRepositoryByName(repoName); Git git = Git.wrap(r); DeleteBranchCommand command = git.branchDelete(); command.setBranchNames(branchName); command.setForce(true); command.call(); r.close(); } catch (IOException e) { throw new RuntimeException(e); } catch (GitAPIException e) { throw new RuntimeException(e); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
From source file:com.verigreen.jgit.JGitOperator.java
License:Apache License
public void deleteBranch(boolean force, String... branchesToDelete) { DeleteBranchCommand branchDelete = _git.branchDelete(); branchDelete.setForce(force); try {/*from w w w . jav a 2s .c o m*/ 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); } }
From source file:org.eclipse.orion.server.git.servlets.GitBranchHandlerV1.java
License:Open Source License
private boolean handleDelete(HttpServletRequest request, HttpServletResponse response, String path) throws IOException, JSONException, ServletException, URISyntaxException, CoreException, JGitInternalException, GitAPIException { // FIXME: what if there is a branch named "file"? Path p = new Path(path); if (p.segment(1).equals("file")) { //$NON-NLS-1$ // branch details: expected path /git/branch/{name}/file/{path} File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1)); Repository db = new FileRepository(gitDir); Git git = new Git(db); DeleteBranchCommand cc = git.branchDelete(); cc.setBranchNames(p.segment(0)); // TODO: the force flag should be passed in the API call cc.setForce(true); cc.call();// w w w . ja v a 2 s . com // TODO: do something with the result, and handle any exceptions return true; } return false; }
From source file:org.mule.module.git.GitConnector.java
License:Open Source License
/** * Delete local branch//from w w w. ja va 2s . co m * * {@sample.xml ../../../doc/mule-module-git.xml.sample git:delete-branch} * * @param branchName Name of the branch to delete * @param force If false 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 * @param overrideDirectory Name of the directory to use for git repository */ @Processor public void deleteBranch(String branchName, boolean force, @Optional String overrideDirectory) { try { Git git = new Git(getGitRepo(overrideDirectory)); DeleteBranchCommand deleteBranch = git.branchDelete(); deleteBranch.setBranchNames(branchName); deleteBranch.setForce(force); deleteBranch.call(); } catch (Exception e) { throw new RuntimeException("Unable to create branch " + branchName, e); } }