Example usage for org.eclipse.jgit.api CleanCommand setIgnore

List of usage examples for org.eclipse.jgit.api CleanCommand setIgnore

Introduction

In this page you can find the example usage for org.eclipse.jgit.api CleanCommand setIgnore.

Prototype

public CleanCommand setIgnore(boolean ignore) 

Source Link

Document

If ignore is set, don't report/clean files/directories that are ignored by a .gitignore.

Usage

From source file:org.eclipse.egit.ui.internal.clean.CleanRepositoryPage.java

License:Open Source License

private void updateCleanItems() {
    try {/*w w w .j a v  a 2s .  c o m*/
        getContainer().run(true, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(UIText.CleanRepositoryPage_findingItems, IProgressMonitor.UNKNOWN);

                Git git = Git.wrap(repository);
                CleanCommand command = git.clean().setDryRun(true);
                command.setCleanDirectories(cleanDirectories);
                command.setIgnore(!includeIgnored);
                try {
                    final Set<String> paths = command.call();

                    getShell().getDisplay().syncExec(new Runnable() {
                        public void run() {
                            cleanTable.setInput(paths);
                        }
                    });
                } catch (GitAPIException ex) {
                    Activator.logError("cannot call clean command!", ex); //$NON-NLS-1$
                }

                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        Activator.logError("Unexpected exception while finding items to clean", e); //$NON-NLS-1$
        clearPage();
    } catch (InterruptedException e) {
        clearPage();
    }
}

From source file:org.eclipse.egit.ui.internal.clean.CleanRepositoryPage.java

License:Open Source License

/**
 * Do the cleaning with the selected values.
 *///ww  w .  j  a  va2s  . c  om
public void finish() {
    try {
        final Set<String> itemsToClean = getItemsToClean();

        getContainer().run(true, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(UIText.CleanRepositoryPage_cleaningItems, IProgressMonitor.UNKNOWN);

                Git git = Git.wrap(repository);
                CleanCommand command = git.clean().setDryRun(false);
                command.setCleanDirectories(cleanDirectories);
                command.setIgnore(!includeIgnored);
                command.setPaths(itemsToClean);
                try {
                    command.call();
                } catch (GitAPIException ex) {
                    Activator.logError("cannot call clean command!", ex); //$NON-NLS-1$
                }

                try {
                    IProject[] projects = ProjectUtil.getProjectsContaining(repository, itemsToClean);
                    ProjectUtil.refreshResources(projects, new SubProgressMonitor(monitor, 1));
                } catch (CoreException e) {
                    // could not refresh... not a "real" problem
                }

                monitor.done();
            }
        });
    } catch (Exception e) {
        Activator.logError("Unexpected exception while cleaning", e); //$NON-NLS-1$
    }
}