use of org.eclipse.jgit.api.ResetCommand in project che by eclipse.
the class JGitConnection method reset.
@Override
public void reset(ResetParams params) throws GitException {
try {
ResetCommand resetCommand = getGit().reset();
resetCommand.setRef(params.getCommit());
List<String> patterns = params.getFilePattern();
patterns.forEach(resetCommand::addPath);
if (params.getType() != null && patterns.isEmpty()) {
switch(params.getType()) {
case HARD:
resetCommand.setMode(ResetType.HARD);
break;
case KEEP:
resetCommand.setMode(ResetType.KEEP);
break;
case MERGE:
resetCommand.setMode(ResetType.MERGE);
break;
case MIXED:
resetCommand.setMode(ResetType.MIXED);
break;
case SOFT:
resetCommand.setMode(ResetType.SOFT);
break;
}
}
resetCommand.call();
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
Aggregations