本文整理了Java中org.eclipse.jgit.api.Git.branchDelete()
方法的一些代码示例,展示了Git.branchDelete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.branchDelete()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:branchDelete
[英]Return a command object used to delete branches
[中]返回用于删除分支的命令对象
代码示例来源:origin: gocd/gocd
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;
}
}
代码示例来源:origin: spring-cloud/spring-cloud-config
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;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public List<String> branchDelete(String[] names, boolean force) throws GitAPIException {
DeleteBranchCommand command = getWrappedObject().branchDelete();
command.setBranchNames(names);
return command.call();
}
代码示例来源:origin: centic9/jgit-cookbook
if(ref.getName().equals("refs/heads/testbranch")) {
System.out.println("Removing branch before");
git.branchDelete()
.setBranchNames("testbranch")
.setForce(true)
git.branchDelete()
.setBranchNames("testbranch")
.call();
代码示例来源:origin: kiegroup/appformer
public DeleteBranchCommand _branchDelete() {
return git.branchDelete();
}
代码示例来源:origin: centic9/jgit-cookbook
if(ref.getName().equals("refs/heads/testbranch")) {
System.out.println("Removing branch before");
git.branchDelete()
.setBranchNames("testbranch")
.setForce(true)
git.branchDelete()
.setBranchNames("testbranch")
.call();
代码示例来源:origin: kiegroup/appformer
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();
}
代码示例来源:origin: Verigreen/verigreen
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);
}
}
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
/**
* 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);
}
}
代码示例来源:origin: org.apache.camel/camel-git
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;
}
}
代码示例来源:origin: com.meltmedia.cadmium/cadmium-core
public void deleteLocalBranch(String branchName) throws Exception {
git.branchDelete().setForce(true).setBranchNames(branchName).call();
}
代码示例来源:origin: io.fabric8/fabric-git
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;
}
}
代码示例来源:origin: mauricioaniche/repodriller
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;
}
}
}
代码示例来源:origin: jboss-fuse/fabric8
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;
}
}
代码示例来源:origin: org.uberfire/vfs-jgit
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);
}
}
代码示例来源:origin: org.kie.commons/kie-nio2-jgit
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 );
}
}
代码示例来源:origin: org.hudsonci.plugins/git
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);
}
}
代码示例来源:origin: mauricioaniche/repodriller
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);
}
}
代码示例来源:origin: jenkinsci/git-client-plugin
/** {@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);
}
}
代码示例来源:origin: bozaro/git-as-svn
@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);
}
内容来源于网络,如有侵权,请联系作者删除!