List of usage examples for org.eclipse.jgit.api CheckoutResult getUndeletedList
public List<String> getUndeletedList()
From source file:com.genuitec.org.eclipse.egit.ui.internal.branch.BranchOperationUI.java
License:Open Source License
/** * @param result/*from w w w. j av a2 s .c om*/ * the result to show */ public void show(final CheckoutResult result) { if (result.getStatus() == CheckoutResult.Status.CONFLICTS) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog( shell, UIText.BranchResultDialog_CheckoutConflictsTitle, NLS.bind(UIText.BranchResultDialog_CheckoutConflictsMessage, Repository.shortenRefName(target)), repository, result.getConflictList()); cleanupUncomittedChangesDialog.open(); if (cleanupUncomittedChangesDialog.shouldContinue()) { BranchOperationUI op = BranchOperationUI.checkoutWithoutQuestion(repository, target) .doneCallback(doneCallback); op.start(); } } }); } else if (result.getStatus() == CheckoutResult.Status.NONDELETED) { // double-check if the files are still there boolean show = false; List<String> pathList = result.getUndeletedList(); for (String path : pathList) if (new File(repository.getWorkTree(), path).exists()) { show = true; break; } if (!show) return; PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); new NonDeletedFilesDialog(shell, repository, result.getUndeletedList()).open(); } }); } else if (result.getStatus() == CheckoutResult.Status.OK) { if (RepositoryUtil.isDetachedHead(repository)) showDetachedHeadWarning(); } if (doneCallback != null) { doneCallback.done(result); } }
From source file:com.rimerosolutions.ant.git.tasks.CheckoutTask.java
License:Apache License
@Override protected void doExecute() throws BuildException { try {// ww w . ja v a 2s .c om CheckoutCommand checkoutCommand = git.checkout(); if (createBranch) { checkoutCommand.setCreateBranch(true); if (trackBranchOnCreate) { checkoutCommand.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK); } } if (!GitTaskUtils.isNullOrBlankString(branchName)) { checkoutCommand.setName(branchName); } if (!GitTaskUtils.isNullOrBlankString(startPoint)) { checkoutCommand.setStartPoint(Constants.DEFAULT_REMOTE_NAME + "/" + startPoint); } checkoutCommand.call(); CheckoutResult checkoutResult = checkoutCommand.getResult(); if (checkoutResult.getStatus().equals(CheckoutResult.Status.CONFLICTS)) { String conflicts = checkoutResult.getConflictList().toString(); throw new GitBuildException(String.format("Conflicts were found:%s.", conflicts)); } else if (checkoutResult.getStatus().equals(CheckoutResult.Status.NONDELETED)) { String undeleted = checkoutResult.getUndeletedList().toString(); throw new GitBuildException(String.format("Some files could not be deleted:%s.", undeleted)); } } catch (RefAlreadyExistsException e) { throw new GitBuildException( String.format("Cannot create branch '%s', as it already exists!", branchName), e); } catch (RefNotFoundException e) { throw new GitBuildException(String.format("The branch '%s' was not found.", branchName), e); } catch (InvalidRefNameException e) { throw new GitBuildException("An invalid branch name was specified.", e); } catch (CheckoutConflictException e) { throw new GitBuildException("Some checkout conflicts were found.", e); } catch (GitAPIException e) { throw new GitBuildException(String.format("Could not checkout branch '%s'.", branchName), e); } }
From source file:org.eclipse.egit.ui.internal.branch.BranchResultDialog.java
License:Open Source License
/** * @param result/* w w w. jav a2 s.co m*/ * the result to show * @param repository * @param target * the target (branch name or commit id) */ public static void show(final CheckoutResult result, final Repository repository, final String target) { BranchResultDialog.target = target; if (result.getStatus() == CheckoutResult.Status.CONFLICTS) PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); new BranchResultDialog(shell, repository, result, target).open(); } }); else if (result.getStatus() == CheckoutResult.Status.NONDELETED) { // double-check if the files are still there boolean show = false; List<String> pathList = result.getUndeletedList(); for (String path : pathList) if (new File(repository.getWorkTree(), path).exists()) { show = true; break; } if (!show) return; PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); new NonDeletedFilesDialog(shell, repository, result.getUndeletedList()).open(); } }); } else if (result.getStatus() == CheckoutResult.Status.OK) { try { if (ObjectId.isId(repository.getFullBranch())) showDetachedHeadWarning(); } catch (IOException e) { Activator.logError(e.getMessage(), e); } } }