List of usage examples for org.eclipse.jgit.api CleanCommand call
@Override public Set<String> call() throws NoWorkTreeException, GitAPIException
Executes the clean command with all the options and parameters collected by the setter methods of this class.
From source file:org.ajoberstar.gradle.git.tasks.GitClean.java
License:Apache License
/** * Reset the changes as configured.//w w w. j a v a2s .co m * If {@code paths} is set, only the specified * paths will be cleaned. Otherwise all paths * will be. */ @TaskAction public void reset() { final CleanCommand cmd = getGit().clean(); cmd.setPaths(getPaths()); try { cmd.call(); } catch (GitAPIException e) { throw new GradleException("Problem with clean.", e); } //TODO add progress monitor to log progress to Gradle status bar }
From source file:org.eclipse.egit.ui.internal.clean.CleanRepositoryPage.java
License:Open Source License
private void updateCleanItems() { try {//from w w w . j a v a2s . 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 w w . ja v a 2s.c o 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);/*ww w . j ava 2 s. c o m*/ clean.call(); }
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; }