Example usage for org.eclipse.jgit.api CheckoutResult getConflictList

List of usage examples for org.eclipse.jgit.api CheckoutResult getConflictList

Introduction

In this page you can find the example usage for org.eclipse.jgit.api CheckoutResult getConflictList.

Prototype

public List<String> getConflictList() 

Source Link

Document

Get list of file that created a checkout conflict

Usage

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  a2s  . c o m*/
 *            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 {//from   w  ww.ja  v  a  2 s .  c o m
        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.fetch.FetchGerritChangePage.java

License:Open Source License

private void createBranch(final String textForBranch, RevCommit commit, IProgressMonitor monitor)
        throws CoreException, GitAPIException {
    monitor.setTaskName(UIText.FetchGerritChangePage_CreatingBranchTaskName);
    CreateLocalBranchOperation bop = new CreateLocalBranchOperation(repository, textForBranch, commit);
    bop.execute(monitor);/*from   w  w w .  j av a 2s . c  o  m*/
    CheckoutCommand co = new Git(repository).checkout();
    try {
        co.setName(textForBranch).call();
    } catch (CheckoutConflictException e) {
        final CheckoutResult result = co.getResult();

        if (result.getStatus() == Status.CONFLICTS) {
            final Shell shell = getWizard().getContainer().getShell();

            shell.getDisplay().asyncExec(new Runnable() {
                public void run() {
                    new CheckoutConflictDialog(shell, repository, result.getConflictList()).open();
                }
            });
        }
    }
    monitor.worked(1);
}