Search in sources :

Example 1 with MergeSorter

use of com.google.gerrit.server.git.MergeSorter in project gerrit by GerritCodeReview.

the class SubmitDryRun method run.

public boolean run(SubmitType submitType, Repository repo, CodeReviewRevWalk rw, Branch.NameKey destBranch, ObjectId tip, ObjectId toMerge, Set<RevCommit> alreadyAccepted) throws IntegrationException, NoSuchProjectException, IOException {
    CodeReviewCommit tipCommit = rw.parseCommit(tip);
    CodeReviewCommit toMergeCommit = rw.parseCommit(toMerge);
    RevFlag canMerge = rw.newFlag("CAN_MERGE");
    toMergeCommit.add(canMerge);
    Arguments args = new Arguments(repo, rw, mergeUtilFactory.create(getProject(destBranch)), new MergeSorter(rw, alreadyAccepted, canMerge, ImmutableSet.of(toMergeCommit)));
    switch(submitType) {
        case CHERRY_PICK:
            return CherryPick.dryRun(args, tipCommit, toMergeCommit);
        case FAST_FORWARD_ONLY:
            return FastForwardOnly.dryRun(args, tipCommit, toMergeCommit);
        case MERGE_ALWAYS:
            return MergeAlways.dryRun(args, tipCommit, toMergeCommit);
        case MERGE_IF_NECESSARY:
            return MergeIfNecessary.dryRun(args, tipCommit, toMergeCommit);
        case REBASE_IF_NECESSARY:
            return RebaseIfNecessary.dryRun(args, repo, tipCommit, toMergeCommit);
        case REBASE_ALWAYS:
            return RebaseAlways.dryRun(args, repo, tipCommit, toMergeCommit);
        default:
            String errorMsg = "No submit strategy for: " + submitType;
            log.error(errorMsg);
            throw new IntegrationException(errorMsg);
    }
}
Also used : IntegrationException(com.google.gerrit.server.git.IntegrationException) RevFlag(org.eclipse.jgit.revwalk.RevFlag) MergeSorter(com.google.gerrit.server.git.MergeSorter) CodeReviewCommit(com.google.gerrit.server.git.CodeReviewCommit)

Aggregations

CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)1 IntegrationException (com.google.gerrit.server.git.IntegrationException)1 MergeSorter (com.google.gerrit.server.git.MergeSorter)1 RevFlag (org.eclipse.jgit.revwalk.RevFlag)1