List of usage examples for org.eclipse.jgit.api RebaseResult getFailingPaths
public Map<String, MergeFailureReason> getFailingPaths()
From source file:com.microsoft.gittf.core.tasks.PullTask.java
License:Open Source License
private TaskStatus rebase(TaskProgressMonitor progressMonitor, ObjectId commitId) { try {//from www . j a va 2s . com getRebaseCommand().setOperation(Operation.BEGIN); getRebaseCommand().setUpstream(commitId); getRebaseCommand().setProgressMonitor(new RebaseMergeJGITProgressMonitor(progressMonitor)); RebaseResult rebaseResults = getRebaseCommand().call(); progressMonitor.endTask(); RebaseResult.Status status = rebaseResults.getStatus(); switch (status) { case UP_TO_DATE: progressMonitor.displayMessage(Messages.getString("PullTask.Rebase.AlreadyUpToDate")); //$NON-NLS-1$ break; case ABORTED: case FAILED: progressMonitor.displayMessage(Messages.formatString("PullTask.Rebase.FailedFormat", //$NON-NLS-1$ ObjectIdUtil.abbreviate(repository, commitId))); displayFailures(progressMonitor, rebaseResults.getFailingPaths()); break; case FAST_FORWARD: case OK: progressMonitor.displayMessage(Messages.formatString("PullTask.Rebase.RebaseSuccessfulFormat", //$NON-NLS-1$ ObjectIdUtil.abbreviate(repository, commitId))); break; case NOTHING_TO_COMMIT: progressMonitor.displayMessage(Messages.formatString("PullTask.Rebase.NothingToCommitFormat", //$NON-NLS-1$ ObjectIdUtil.abbreviate(repository, commitId))); break; case STOPPED: progressMonitor.displayMessage(Messages.formatString("PullTask.Rebase.StoppedFormat", //$NON-NLS-1$ ObjectIdUtil.abbreviate(repository, commitId))); break; } RepositoryUtil.fixFileAttributes(repository); } catch (Exception e) { log.error("An error occurred while merging.", e); //$NON-NLS-1$ return new TaskStatus(TaskStatus.ERROR, e); } return TaskStatus.OK_STATUS; }
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;/* w w w. j a 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.exist.git.xquery.Pull.java
License:Open Source License
@Override public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { try {//from www. j a va 2 s. c om String localPath = args[0].getStringValue(); if (!(localPath.endsWith("/"))) localPath += File.separator; Git git = Git.open(new Resource(localPath), FS); PullResult answer = git.pull().setCredentialsProvider( new UsernamePasswordCredentialsProvider(args[1].getStringValue(), args[2].getStringValue())) .call(); MemTreeBuilder builder = getContext().getDocumentBuilder(); int nodeNr = builder.startElement(PULL, null); builder.addAttribute(IS_SUCCESSFUL, Boolean.toString(answer.isSuccessful())); MergeResult merge = answer.getMergeResult(); if (merge != null) { builder.startElement(MERGE, null); builder.addAttribute(STATUS, merge.getMergeStatus().toString()); builder.addAttribute(IS_SUCCESSFUL, Boolean.toString(merge.getMergeStatus().isSuccessful())); for (ObjectId commit : merge.getMergedCommits()) { builder.startElement(COMMIT, null); builder.addAttribute(ID, commit.name()); builder.endElement(); } builder.endElement(); if (merge.getConflicts() != null) { for (Entry<String, int[][]> entry : merge.getConflicts().entrySet()) { builder.startElement(CHECKOUT_CONFLICT, null); builder.addAttribute(PATH, entry.getKey()); builder.endElement(); } } if (merge.getCheckoutConflicts() != null) { for (String path : merge.getCheckoutConflicts()) { builder.startElement(CHECKOUT_CONFLICT, null); builder.addAttribute(PATH, path); builder.endElement(); } } if (merge.getFailingPaths() != null) { for (Entry<String, MergeFailureReason> entry : merge.getFailingPaths().entrySet()) { builder.startElement(FAILING_PATH, null); builder.addAttribute(PATH, entry.getKey()); builder.addAttribute(REASON, entry.getValue().name()); builder.endElement(); } } } RebaseResult rebase = answer.getRebaseResult(); if (rebase != null) { builder.startElement(REBASE, null); builder.addAttribute(STATUS, rebase.getStatus().toString()); builder.addAttribute(IS_SUCCESSFUL, Boolean.toString(rebase.getStatus().isSuccessful())); //rebase.getConflicts() if (rebase.getFailingPaths() != null) { for (Entry<String, MergeFailureReason> entry : rebase.getFailingPaths().entrySet()) { builder.startElement(FAILING_PATH, null); builder.addAttribute(PATH, entry.getKey()); builder.addAttribute(REASON, entry.getValue().name()); builder.endElement(); } } builder.endElement(); } return builder.getDocument().getNode(nodeNr); } catch (Throwable e) { e.printStackTrace(); throw new XPathException(this, Module.EXGIT001, e); } }