private MergeResult merge(Git git, String label) { try { MergeCommand merge = git.merge(); merge.include(git.getRepository().findRef("origin/" + label)); MergeResult result = merge.call(); if (!result.getMergeStatus().isSuccessful()) { this.logger.warn("Merged from remote " + label + " with result " + result.getMergeStatus()); } return result; } catch (Exception ex) { String message = "Could not merge remote for " + label + " remote: " + git .getRepository().getConfig().getString("remote", "origin", "url"); warn(message, ex); return null; } }
String getMergedConfig(String branchName, RevCommit newCommit) throws GitAPIException, IOException { MergeResult result = null; try { checkout(branchName); result = git.merge().include(newCommit).call(); } catch (GitAPIException e) { LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName()); throw e; } if (!result.getMergeStatus().isSuccessful()) { LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed as config file has changed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName()); throw new ConfigFileHasChangedException(); } LOGGER.info("[CONFIG_MERGE] Successfully merged commit {} by user {} to branch {}. Merge commit revision is {}", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName()); return FileUtils.readFileToString(new File(workingDir, CRUISE_CONFIG_XML), UTF_8); }
public static ArrayMemory valueOf(MergeResult call) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("base").assign(valueOf(call.getBase())); memory.refOfIndex("newHead").assign(valueOf(call.getNewHead())); memory.refOfIndex("status").assign(call.getMergeStatus().name()); memory.refOfIndex("success").assign(call.getMergeStatus().isSuccessful()); memory.refOfIndex("checkoutConflicts").assign(ArrayMemory.ofStringCollection(call.getCheckoutConflicts())); return memory; }
/** * Whether the pull was successful * * @return whether the pull was successful */ public boolean isSuccessful() { if (mergeResult != null) return mergeResult.getMergeStatus().isSuccessful(); else if (rebaseResult != null) return rebaseResult.getStatus().isSuccessful(); return true; }
PullResult result = pullCmd.call(); FetchResult fetchResult = result.getFetchResult(); MergeResult mergeResult = result.getMergeResult(); mergeResult.getMergeStatus(); // this should be interesting
private boolean hasMergeResults() { final MergeResult mergeResult = result.getMergeResult(); return mergeResult != null && mergeResult.getMergeStatus() != MergeStatus.ALREADY_UP_TO_DATE; }
public boolean developHasProblems() { return !developResult.getMergeStatus().isSuccessful(); }
public boolean masterHasProblems() { return !masterResult.getMergeStatus().isSuccessful(); }
public boolean masterHasProblems() { return !masterResult.getMergeStatus().isSuccessful(); }
protected boolean checkMergeResults(MergeResult... resultsToCheck) { boolean isSuccess = true; for (MergeResult result : resultsToCheck) { if (!result.getMergeStatus().isSuccessful()) { isSuccess = false; break; } } return isSuccess; }
protected boolean checkMergeResults(MergeResult... resultsToCheck) { boolean isSuccess = true; for (MergeResult result : resultsToCheck) { if (!result.getMergeStatus().isSuccessful()) { isSuccess = false; break; } } return isSuccess; }
public boolean developHasProblems() { return !developResult.getMergeStatus().isSuccessful(); }
public boolean masterHasProblems() { return !masterResult.getMergeStatus().isSuccessful(); }
public boolean developHasProblems() { return !developResult.getMergeStatus().isSuccessful(); }
merge.include(newParents.get(i)); MergeResult mergeResult = merge.call(); if (mergeResult.getMergeStatus().isSuccessful()) { CommitCommand commit = git.commit(); commit.setAuthor(commitToPick.getAuthorIdent()); } else { if (operation == Operation.BEGIN && mergeResult .getMergeStatus() == MergeResult.MergeStatus.FAILED) return abort(RebaseResult .failed(mergeResult.getFailingPaths()));
/** * Resolve merge conflict for fabric-mode patching of profile data. */ protected void handleMergeConflict(Git fork, MergeResult result, String versionBranch, String patchBranch) throws GitAPIException, IOException { if (result.getMergeStatus() == MergeResult.MergeStatus.CONFLICTING) { Activator.log2(LogService.LOG_WARNING, "Problem with merging branch \"" + versionBranch + "\" and \"" + patchBranch + "\""); // preferNew == true, because we prefer patch version. // here we handle only R patch and we're merging patch branch into current version branch. // that's why: // patch branch == "theirs" == "3" in `git ls-files -u` == DirCacheEntry.STAGE_3 == threeWayMerge[2] handleConflict(null, fork, true, null, false, "change from patch", null, false); } }
/** * @param parentShell * @param repository * @param mergeResult * @return the created dialog */ public static Dialog getDialog(Shell parentShell, Repository repository, MergeResult mergeResult) { if(mergeResult.getMergeStatus() == MergeStatus.CHECKOUT_CONFLICT) return new CheckoutConflictDialog(parentShell, repository, mergeResult.getCheckoutConflicts()); else return new MergeResultDialog(parentShell, repository, mergeResult); }
/** * @return whether the pull was successful */ public boolean isSuccessful() { if (mergeResult != null) return mergeResult.getMergeStatus().isSuccessful(); else if (rebaseResult != null) return rebaseResult.getStatus().isSuccessful(); return true; }
/** * Whether the pull was successful * * @return whether the pull was successful */ public boolean isSuccessful() { if (mergeResult != null) return mergeResult.getMergeStatus().isSuccessful(); else if (rebaseResult != null) return rebaseResult.getStatus().isSuccessful(); return true; }
Git git = ... // you get it through a CloneCommand, InitCommand // or through the file system CheckoutCommand coCmd = git.checkout(); // Commands are part of the api module, which include git-like calls coCmd.setName("master"); coCmd.setCreateBranch(false); // probably not needed, just to make sure coCmd.call(); // switch to "master" branch MergeCommand mgCmd = git.merge(); mgCmd.include("foo"); // "foo" is considered as a Ref to a branch MergeResult res = mgCmd.call(); // actually do the merge if (res.getMergeStatus().equals(MergeResult.MergeStatus.CONFLICTING)){ System.out.println(res.getConflicts().toString()); // inform the user he has to handle the conflicts }