List of usage examples for org.eclipse.jgit.api MergeResult getMergedCommits
public ObjectId[] getMergedCommits()
From source file:br.com.riselabs.cotonet.test.helpers.ConflictBasedRepositoryTestCase.java
License:Open Source License
public static void printMergeResult(MergeResult result) { Map<String, int[][]> allConflicts = result.getConflicts(); // looping over the files for (String path : allConflicts.keySet()) { int[][] c = allConflicts.get(path); System.out.println("Conflicts in file " + path); // looping over the file conflicts for (int i = 0; i < c.length; ++i) { System.out.println(" Conflict #" + i); // looping over the conflicting chunks. for (int j = 0; j < (c[i].length) - 1; ++j) { if (c[i][j] >= 0) System.out.println( " Chunk for " + result.getMergedCommits()[j] + " starts on line #" + c[i][j]); }/* w ww . jav a 2 s. co m*/ } } }
From source file:com.verigreen.jgit.JGitOperator.java
License:Apache License
private String createMessageAutoCommit(MergeResult mergeResult) { StringBuffer message = new StringBuffer("Auto merge commit between:"); for (Object commit : mergeResult.getMergedCommits()) { message.append(" ").append(((RevCommit) commit).getName().substring(0, 7));//no check for null }/*from ww w . j ava2s.c o m*/ return message.toString(); }
From source file:org.eclipse.egit.gitflow.ui.internal.actions.FeatureFinishHandler.java
License:Open Source License
private void postMerge(final GitFlowRepository gfRepo, final String featureBranch, final boolean squash, final MergeResult mergeResult) { Display display = Display.getDefault(); display.asyncExec(new Runnable() { @Override/* ww w.jav a 2 s .c o m*/ public void run() { Shell activeShell = Display.getDefault().getActiveShell(); if (squash && mergeResult.getMergedCommits().length > 1) { try { rewordCommitMessage(activeShell, gfRepo); } catch (CoreException | IOException e) { throw new RuntimeException(e); } } MergeStatus mergeStatus = mergeResult.getMergeStatus(); if (MergeStatus.CONFLICTING.equals(mergeStatus)) { String develop = gfRepo.getConfig().getDevelop(); MultiStatus status = createMergeConflictInfo(develop, featureBranch, mergeResult); ErrorDialog.openError(null, UIText.FeatureFinishHandler_Conflicts, null, status); } } }); }
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 w w w . j a v a 2 s .co m 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); } }
From source file:org.flowerplatform.web.git.GitUtils.java
License:Open Source License
public String handleMergeResult(MergeResult mergeResult) { StringBuilder sb = new StringBuilder(); if (mergeResult == null) { return sb.toString(); }//from w ww . j ava 2s .c om sb.append("Status: "); sb.append(mergeResult.getMergeStatus()); sb.append("\n"); if (mergeResult.getMergedCommits() != null) { sb.append("\nMerged commits: "); sb.append("\n"); for (ObjectId id : mergeResult.getMergedCommits()) { sb.append(id.getName()); sb.append("\n"); } } if (mergeResult.getCheckoutConflicts() != null) { sb.append("\nConflicts: "); sb.append("\n"); for (String conflict : mergeResult.getCheckoutConflicts()) { sb.append(conflict); sb.append("\n"); } } if (mergeResult.getFailingPaths() != null) { sb.append("\nFailing paths: "); sb.append("\n"); for (String path : mergeResult.getFailingPaths().keySet()) { sb.append(path); sb.append(" -> "); sb.append(mergeResult.getFailingPaths().get(path).toString()); sb.append("\n"); } } return sb.toString(); }
From source file:playRepository.GitConflicts.java
License:Apache License
/** * MergeResult? #conflictFiles ?? #conflicts ?? . * * @param repository/* w w w . j a v a 2 s . c o m*/ * @param mergeResult * @see http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/api/MergeResult.html#getConflicts() */ public GitConflicts(Repository repository, MergeResult mergeResult) { Map<String, int[][]> allConflicts = mergeResult.getConflicts(); for (String path : allConflicts.keySet()) { conflictFiles.add(path); int[][] conflicts = allConflicts.get(path); for (int[] c : conflicts) { Conflict conflict = new Conflict(); conflict.fileName = path; for (int j = 0; j < (c.length) - 1; ++j) { if (c[j] >= 0) { ObjectId objectId = mergeResult.getMergedCommits()[j]; RevWalk revWalk = new RevWalk(repository); CommitAndLine commitAndLine = new CommitAndLine(); try { commitAndLine.gitCommit = new GitCommit(revWalk.parseCommit(objectId)); commitAndLine.lineNumber = c[j]; conflict.commitAndLines.add(commitAndLine); } catch (IOException e) { throw new RuntimeException(e); } } } conflictDetails.add(conflict); } } }