List of usage examples for org.eclipse.jgit.api RebaseResult getConflicts
public List<String> getConflicts()
From source file:org.dstadler.jgit.porcelain.RebaseToOriginMaster.java
License:Apache License
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { // all refs try (Git git = new Git(repository)) { InteractiveHandler handler = new InteractiveHandler() { @Override/*from w w w. j a v a 2s . co m*/ public void prepareSteps(List<RebaseTodoLine> steps) { // the handler receives the list of commits that are rebased, i.e. the ones on the local branch for (RebaseTodoLine step : steps) { // for each step, you can decide which action should be taken // default is PICK try { // by selecting "EDIT", the rebase will stop and ask you to edit the commit-contents step.setAction(Action.EDIT); } catch (IllegalTodoFileModification e) { throw new IllegalStateException(e); } } } @Override public String modifyCommitMessage(String oldMessage) { return oldMessage; } }; RebaseResult result = git.rebase().setUpstream("origin/master").runInteractively(handler).call(); System.out.println("Rebase had state: " + result.getStatus() + ": " + result.getConflicts()); // because of the "EDIT" in the InteractiveHandler, the rebase was stopped in-between // now you can adjust the commit and continue rebasing with setOperation(RebaseCommand.Operation.CONTINUE) // to use the local changes for the commit or setOperation(RebaseCommand.Operation.SKIP) to skip this // commit (i.e. remove it from the branch!) if (!result.getStatus().isSuccessful()) { // if rebasing stopped or failed, you can get back to the original state by running it with setOperation(RebaseCommand.Operation.ABORT) result = git.rebase().setUpstream("origin/master").runInteractively(handler) .setOperation(RebaseCommand.Operation.ABORT).call(); System.out.println( "Aborted reabse with state: " + result.getStatus() + ": " + result.getConflicts()); } } } }
From source file:org.eclipse.che.git.impl.jgit.JGitConnection.java
License:Open Source License
@Override public RebaseResponse rebase(RebaseRequest request) throws GitException { RebaseResult result; RebaseStatus status;//from w w w . ja va 2 s. c om List<String> failed; List<String> conflicts; try { RebaseCommand rebaseCommand = getGit().rebase(); setRebaseOperation(rebaseCommand, request); String branch = request.getBranch(); if (branch != null && !branch.isEmpty()) { rebaseCommand.setUpstream(branch); } result = rebaseCommand.call(); } catch (GitAPIException exception) { throw new GitException(exception.getMessage(), exception); } switch (result.getStatus()) { case ABORTED: status = RebaseStatus.ABORTED; break; case CONFLICTS: status = RebaseStatus.CONFLICTING; break; case UP_TO_DATE: status = RebaseStatus.ALREADY_UP_TO_DATE; break; case FAST_FORWARD: status = RebaseStatus.FAST_FORWARD; break; case NOTHING_TO_COMMIT: status = RebaseStatus.NOTHING_TO_COMMIT; break; case OK: status = RebaseStatus.OK; break; case STOPPED: status = RebaseStatus.STOPPED; break; case UNCOMMITTED_CHANGES: status = RebaseStatus.UNCOMMITTED_CHANGES; break; case EDIT: status = RebaseStatus.EDITED; break; case INTERACTIVE_PREPARED: status = RebaseStatus.INTERACTIVE_PREPARED; break; case STASH_APPLY_CONFLICTS: status = RebaseStatus.STASH_APPLY_CONFLICTS; break; default: status = RebaseStatus.FAILED; } conflicts = result.getConflicts() != null ? result.getConflicts() : Collections.emptyList(); failed = result.getFailingPaths() != null ? new ArrayList<>(result.getFailingPaths().keySet()) : Collections.emptyList(); return newDto(RebaseResponse.class).withStatus(status).withConflicts(conflicts).withFailed(failed); }
From source file:org.eclipse.egit.gitflow.ui.internal.actions.AbstractGitFlowHandler.java
License:Open Source License
/** * @param rebaseResult/*from ww w .j a va 2 s .com*/ * @return Status containing detailed information about what went wrong * during rebase */ protected MultiStatus createRebaseConflictWarning(RebaseResult rebaseResult) { Iterable<String> paths = rebaseResult.getConflicts(); return docreateConflictWarning(paths, UIText.AbstractGitFlowHandler_rebaseConflicts); }
From source file:org.eclipse.egit.gitflow.ui.internal.actions.FeatureRebaseHandler.java
License:Open Source License
private void openWarning(RebaseResult operationResult) { RebaseResult.Status status = operationResult.getStatus(); String pluginId = Activator.getPluginId(); MultiStatus info = new MultiStatus(pluginId, 1, UIText.FeatureRebaseHandler_problemsOcccurredDuringRebase, null);// w w w . j a v a2 s . co m info.add(new Status(IStatus.WARNING, pluginId, NLS.bind(UIText.FeatureRebaseHandler_statusWas, status.name()))); if (operationResult.getConflicts() != null && !operationResult.getConflicts().isEmpty()) { MultiStatus warning = createRebaseConflictWarning(operationResult); info.addAll(warning); } ErrorDialog.openError(null, UIText.FeatureRebaseHandler_problemsOccurred, null, info); }