private void wantTag(Ref r) throws TransportException { want(r, new RefSpec().setSource(r.getName()) .setDestination(r.getName()).setForceUpdate(true)); }
protected static Set<RefSpec> mirror(String... refs) { HashSet<RefSpec> r = new HashSet<RefSpec>(); for (String name : refs) { RefSpec rs = new RefSpec(name); rs = rs.setDestination(name); rs = rs.setForceUpdate(true); r.add(rs); } return r; }
public void modifyText(ModifyEvent e) { if (destinationText.isFocusControl()) setSpec(getSpec().setDestination(destinationText.getText())); } });
/** * Mirror refs * * @param refs * @return set of RefSpecs */ protected static Set<RefSpec> mirror(String... refs) { HashSet<RefSpec> r = new HashSet<>(); for (String name : refs) { RefSpec rs = new RefSpec(name); rs = rs.setDestination(name); rs = rs.setForceUpdate(true); r.add(rs); } return r; }
public void modifyText(ModifyEvent e) { if (sourceText.isFocusControl()) if (autoSuggestDestination) { String name = sourceText.getText(); if (name.startsWith(Constants.R_HEADS)) name = name.substring(Constants.R_HEADS.length()); else if (name.startsWith(Constants.R_TAGS)) name = name.substring(Constants.R_TAGS.length()); RefSpec sourceChanged = getSpec().setSource( sourceText.getText()); setSpec(sourceChanged .setDestination(Constants.R_REMOTES + config.getName() + '/' + name)); } else setSpec(getSpec().setSource(sourceText.getText())); } });
boolean doFetch() { .setDestination(Constants.FETCH_HEAD); final String uri = uriCombo.getText(); final boolean doCheckout = checkout.getSelection();
private void wantTag(final Ref r) throws TransportException { want(r, new RefSpec().setSource(r.getName()) .setDestination(r.getName()).setForceUpdate(true)); }
private void wantTag(Ref r) throws TransportException { want(r, new RefSpec().setSource(r.getName()) .setDestination(r.getName()).setForceUpdate(true)); }
public Void call(Git git, GitContext context) throws Exception { removeVersionFromCaches(versionId); GitHelpers.removeBranch(git, versionId); git.push().setTimeout(gitTimeout) .setCredentialsProvider(getCredentialsProvider()) .setRefSpecs(new RefSpec().setSource(null).setDestination("refs/heads/" + versionId)) .call(); return null; } };
public Void call(Git git, GitContext context) throws Exception { removeVersionFromCaches(versionId); GitHelpers.removeBranch(git, versionId); git.push().setTimeout(gitTimeout) .setCredentialsProvider(getCredentialsProvider()) .setRefSpecs(new RefSpec().setSource(null).setDestination("refs/heads/" + versionId)) .call(); return null; } };
public static void deleteBranch(Path targetDirectory, String branch, boolean deleteRemoteBranch){ Git repository = null; try { repository = Git.open(targetDirectory.toFile()); //delete locally if (branchExistsLocally(repository, branch)) { // is current branch? if(repository.getRepository().getBranch().equals(branch)){ checkoutExistingBranchOrCreateOrphan(repository, true, null,null, "tmp"); } repository.branchDelete().setForce(true).setBranchNames("refs/heads/" + branch).call(); } // delete remote branch if(deleteRemoteBranch){ RefSpec refSpec = new RefSpec() .setSource(null) .setDestination("refs/heads/" + branch); repository.push().setRefSpecs(refSpec).setRemote("origin").call(); } } catch (IOException | GitAPIException e) { throw new GitException("Error while deleting branch <" + branch + ">", e); } finally { close(repository); } }
.setDestination( Constants.R_TAGS + escapedTagName );
/** * Use with care! */ public boolean deleteBranch() { if (!branch.startsWith("feature/")) { throw new GitException("Can only delete feature branch."); } try { final Git git = gitOpen(); git.checkout().setCreateBranch(true).setName("feature/temp_" + UUID.randomUUID()).call(); List<String> deletedBranches = git.branchDelete().setBranchNames(branch).setForce(true).call(); if (deletedBranches.size() == 1) { // delete branch 'branchToDelete' on remote 'origin' RefSpec refSpec = new RefSpec().setSource(null).setDestination("refs/heads/" + branch); Iterable<PushResult> results = git.push().setCredentialsProvider(credentialsProvider()).setRefSpecs(refSpec).setRemote("origin").call(); for (PushResult result : results) { RemoteRefUpdate myUpdate = result.getRemoteUpdate("refs/heads/" + branch); if (myUpdate.isDelete() && myUpdate.getStatus() == RemoteRefUpdate.Status.OK) { return true; } } } return false; } catch (IOException | GitAPIException e) { throw new GitException("Delete branch failed", e); } }
.setDestination("refs/heads/" + branch); Iterable<PushResult> results = git.push() .setCredentialsProvider(credentialsProvider())
.setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + entry.getKey())) .call();
.setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + entry.getKey())) .call();
.setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + currentBaseline.getTagName())) .call(); .setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + entry.getKey())) .call(); .setRefSpecs(new RefSpec() .setSource(null) .setDestination(String.format("refs/tags/%s", patchTagName))) .call();
.setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + currentBaseline.getTagName())) .call(); .setRefSpecs(new RefSpec() .setSource(null) .setDestination("refs/tags/" + entry.getKey())) .call(); .setRefSpecs(new RefSpec() .setSource(null) .setDestination(String.format("refs/tags/%s", patchTagName))) .call();
protected void cleanupBranchesIfNeeded(String branchToCheckout, String... branchesToDelete) throws GitAPIException, JGitFlowGitAPIException { if (!keepBranch) { git.checkout().setName(branchToCheckout).call(); for (String branchToDelete : branchesToDelete) { if (GitHelper.localBranchExists(git, branchToDelete)) { reporter.infoText(getCommandName(), "deleting local branch: " + branchToDelete); git.branchDelete().setForce(forceDeleteBranch).setBranchNames(branchToDelete).call(); } if (isPush() && GitHelper.remoteBranchExists(git, branchToDelete)) { reporter.infoText(getCommandName(), "pushing deleted branch: :" + branchToDelete); RefSpec deleteSpec = new RefSpec().setSource(null).setDestination(Constants.R_HEADS + branchToDelete); git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(deleteSpec).call(); } } } }
protected void cleanupBranchesIfNeeded(String branchToCheckout, String... branchesToDelete) throws GitAPIException, JGitFlowGitAPIException { if (!keepBranch) { git.checkout().setName(branchToCheckout).call(); for (String branchToDelete : branchesToDelete) { if (GitHelper.localBranchExists(git, branchToDelete)) { reporter.infoText(getCommandName(), "deleting local branch: " + branchToDelete); git.branchDelete().setForce(forceDeleteBranch).setBranchNames(branchToDelete).call(); } if (isPush() && GitHelper.remoteBranchExists(git, branchToDelete)) { reporter.infoText(getCommandName(), "pushing deleted branch: :" + branchToDelete); RefSpec deleteSpec = new RefSpec().setSource(null).setDestination(Constants.R_HEADS + branchToDelete); git.push().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(deleteSpec).call(); } } } }