Search in sources :

Example 1 with MultipleParentsNotAllowedException

use of org.eclipse.jgit.api.errors.MultipleParentsNotAllowedException in project archi-modelrepository-plugin by archi-contribs.

the class RevertCommitsAction method doRevertCommand.

@Override
protected RevertCommand doRevertCommand(Git git) throws GitAPIException, IOException {
    RevertCommand revertCommand = git.revert();
    try (RevWalk revWalk = new RevWalk(git.getRepository())) {
        // We are interested in the HEAD
        revWalk.markStart(revWalk.parseCommit(git.getRepository().resolve(IGraficoConstants.HEAD)));
        for (RevCommit c : revWalk) {
            if (c.getParentCount() > 1) {
                throw new MultipleParentsNotAllowedException(NLS.bind(Messages.RevertCommitsAction_1, c.getName()));
            }
            if (c.equals(fCommit)) {
                break;
            }
            revertCommand.include(c);
        }
        revWalk.dispose();
    }
    revertCommand.call();
    return revertCommand;
}
Also used : RevertCommand(org.eclipse.jgit.api.RevertCommand) RevWalk(org.eclipse.jgit.revwalk.RevWalk) MultipleParentsNotAllowedException(org.eclipse.jgit.api.errors.MultipleParentsNotAllowedException) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

RevertCommand (org.eclipse.jgit.api.RevertCommand)1 MultipleParentsNotAllowedException (org.eclipse.jgit.api.errors.MultipleParentsNotAllowedException)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1