List of usage examples for org.eclipse.jgit.api CleanCommand setCleanDirectories
public CleanCommand setCleanDirectories(boolean dirs)
From source file:org.eclipse.egit.ui.internal.clean.CleanRepositoryPage.java
License:Open Source License
private void updateCleanItems() { try {//from w ww . j a v a 2 s. 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. *///from w ww . j a v a 2s . co m 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$ } }
From source file:org.eclipse.winery.repository.backend.filebased.GitBasedRepository.java
License:Open Source License
private void clean() throws NoWorkTreeException, GitAPIException { // remove untracked files CleanCommand clean = this.git.clean(); clean.setCleanDirectories(true); clean.call();//from w ww .j av a 2 s . co m }
From source file:org.jabylon.team.git.GitTeamProvider.java
License:Open Source License
@Override public Collection<PropertyFileDiff> reset(ProjectVersion project, IProgressMonitor monitor) throws TeamProviderException { List<PropertyFileDiff> updatedFiles = new ArrayList<PropertyFileDiff>(); try {//from w w w. j a v a 2 s .c o m Repository repository = createRepository(project); SubMonitor subMon = SubMonitor.convert(monitor, "Reset", 100); Git git = new Git(repository); subMon.subTask("Calculating Diff"); DiffCommand diffCommand = git.diff(); diffCommand.setProgressMonitor(new ProgressMonitorWrapper(subMon.newChild(30))); diffCommand.setOldTree(prepareTreeParser(repository, "refs/remotes/origin/" + project.getName())); diffCommand.setNewTree(null); List<DiffEntry> diffs = diffCommand.call(); for (DiffEntry diffEntry : diffs) { checkCanceled(monitor); PropertyFileDiff fileDiff = createDiff(diffEntry, monitor); revertDiff(fileDiff); updatedFiles.add(fileDiff); } subMon.subTask("Executing Reset"); ResetCommand reset = git.reset(); reset.setMode(ResetType.HARD); reset.setRef("refs/remotes/origin/" + project.getName()); reset.call(); CleanCommand clean = git.clean(); clean.setCleanDirectories(true); Set<String> call = clean.call(); LOGGER.info("cleaned " + call); } catch (IOException e) { LOGGER.error("reset failed", e); throw new TeamProviderException(e); } catch (GitAPIException e) { LOGGER.error("reset failed", e); throw new TeamProviderException(e); } return updatedFiles; }