use of org.eclipse.jgit.api.CleanCommand in project egit by eclipse.
the class CleanRepositoryPage method updateCleanItems.
private void updateCleanItems() {
try {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
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() {
@Override
public void run() {
cleanTable.setInput(paths);
}
});
} catch (GitAPIException ex) {
// $NON-NLS-1$
Activator.logError("cannot call clean command!", ex);
}
monitor.done();
}
});
updatePageComplete();
} catch (InvocationTargetException e) {
// $NON-NLS-1$
Activator.logError("Unexpected exception while finding items to clean", e);
clearPage();
} catch (InterruptedException e) {
clearPage();
}
}
use of org.eclipse.jgit.api.CleanCommand in project egit by eclipse.
the class CleanRepositoryPage method finish.
/**
* Do the cleaning with the selected values.
*/
public void finish() {
try {
final Set<String> itemsToClean = getItemsToClean();
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, UIText.CleanRepositoryPage_cleaningItems, 1);
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) {
// $NON-NLS-1$
Activator.logError("cannot call clean command!", ex);
}
try {
IProject[] projects = ProjectUtil.getProjectsContaining(repository, itemsToClean);
ProjectUtil.refreshResources(projects, subMonitor.newChild(1));
} catch (CoreException e) {
// could not refresh... not a "real" problem
}
}
});
} catch (Exception e) {
// $NON-NLS-1$
Activator.logError("Unexpected exception while cleaning", e);
}
}
use of org.eclipse.jgit.api.CleanCommand in project winery by eclipse.
the class GitBasedRepository method clean.
private void clean() throws NoWorkTreeException, GitAPIException {
// remove untracked files
try (Git git = getGit()) {
CleanCommand clean = git.clean();
clean.setCleanDirectories(true);
clean.call();
} catch (IOException e) {
LOGGER.error("Error initializing Git.", e);
}
}
use of org.eclipse.jgit.api.CleanCommand in project archi-modelrepository-plugin by archi-contribs.
the class ArchiRepository method resetToRef.
@Override
public void resetToRef(String ref) throws IOException, GitAPIException {
// Check lock file is deleted
checkDeleteLockFile();
try (Git git = Git.open(getLocalRepositoryFolder())) {
// Reset to master
ResetCommand resetCommand = git.reset();
resetCommand.setRef(ref);
resetCommand.setMode(ResetType.HARD);
resetCommand.call();
// Clean extra files
CleanCommand cleanCommand = git.clean();
cleanCommand.setCleanDirectories(true);
cleanCommand.call();
}
}
Aggregations