use of org.eclipse.jgit.api.RmCommand in project che by eclipse.
the class JGitConnection method addDeletedFilesToIndex.
/** To add deleted files in index it is required to perform git rm on them */
private void addDeletedFilesToIndex(List<String> filePatterns) throws GitAPIException {
Set<String> deletedFiles = getGit().status().call().getMissing();
if (!deletedFiles.isEmpty()) {
RmCommand rmCommand = getGit().rm();
if (filePatterns.contains(".")) {
deletedFiles.forEach(rmCommand::addFilepattern);
} else {
filePatterns.forEach(filePattern -> deletedFiles.stream().filter(deletedFile -> deletedFile.startsWith(filePattern)).forEach(rmCommand::addFilepattern));
}
rmCommand.call();
}
}
use of org.eclipse.jgit.api.RmCommand in project che by eclipse.
the class JGitConnection method rm.
@Override
public void rm(RmParams params) throws GitException {
List<String> files = params.getItems();
RmCommand rmCommand = getGit().rm();
rmCommand.setCached(params.isCached());
if (files != null) {
files.forEach(rmCommand::addFilepattern);
}
try {
rmCommand.call();
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
use of org.eclipse.jgit.api.RmCommand in project indy by Commonjava.
the class GitManager method deleteAndCommitPaths.
public GitManager deleteAndCommitPaths(final ChangeSummary summary, final Collection<String> paths) throws GitSubsystemException {
lockAnd(me -> {
try {
RmCommand rm = git.rm();
CommitCommand commit = git.commit();
for (final String path : paths) {
rm = rm.addFilepattern(path);
commit = commit.setOnly(path);
}
logger.info("Deleting:\n " + join(paths, "\n ") + "\n\nSummary: " + summary);
rm.call();
commit.setMessage(buildMessage(summary, paths)).setAuthor(summary.getUser(), email).call();
} catch (final NoFilepatternException e) {
throw new GitSubsystemException("Cannot remove from git: " + e.getMessage(), e);
} catch (final JGitInternalException | GitAPIException e) {
throw new GitSubsystemException("Cannot remove from git: " + e.getMessage(), e);
}
return me;
});
return this;
}
Aggregations