Search in sources :

Example 1 with OpenBranch

use of com.google.gerrit.server.submit.MergeOpRepoManager.OpenBranch in project gerrit by GerritCodeReview.

the class MergeOp method getSubmitStrategies.

private List<SubmitStrategy> getSubmitStrategies(Map<BranchNameKey, BranchBatch> toSubmit, UpdateOrderCalculator updateOrderCalculator, SubmoduleCommits submoduleCommits, SubscriptionGraph subscriptionGraph, boolean dryrun) throws IntegrationConflictException, NoSuchProjectException, IOException {
    List<SubmitStrategy> strategies = new ArrayList<>();
    Set<BranchNameKey> allBranches = updateOrderCalculator.getBranchesInOrder();
    Set<CodeReviewCommit> allCommits = toSubmit.values().stream().map(BranchBatch::commits).flatMap(Set::stream).collect(toSet());
    for (BranchNameKey branch : allBranches) {
        OpenRepo or = orm.getRepo(branch.project());
        if (toSubmit.containsKey(branch)) {
            BranchBatch submitting = toSubmit.get(branch);
            logger.atFine().log("adding ops for branch batch %s", submitting);
            OpenBranch ob = or.getBranch(branch);
            requireNonNull(submitting.submitType(), String.format("null submit type for %s; expected to previously fail fast", submitting));
            Set<CodeReviewCommit> commitsToSubmit = submitting.commits();
            ob.mergeTip = new MergeTip(ob.oldTip, commitsToSubmit);
            SubmitStrategy strategy = submitStrategyFactory.create(submitting.submitType(), or.rw, or.canMergeFlag, getAlreadyAccepted(or, ob.oldTip), allCommits, branch, caller, ob.mergeTip, commitStatus, submissionId, submitInput, submoduleCommits, subscriptionGraph, dryrun);
            strategies.add(strategy);
            strategy.addOps(or.getUpdate(), commitsToSubmit);
        }
    }
    return strategies;
}
Also used : MergeTip(com.google.gerrit.server.git.MergeTip) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ArrayList(java.util.ArrayList) OpenRepo(com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo) CodeReviewCommit(com.google.gerrit.server.git.CodeReviewCommit) OpenBranch(com.google.gerrit.server.submit.MergeOpRepoManager.OpenBranch)

Aggregations

BranchNameKey (com.google.gerrit.entities.BranchNameKey)1 CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)1 MergeTip (com.google.gerrit.server.git.MergeTip)1 OpenBranch (com.google.gerrit.server.submit.MergeOpRepoManager.OpenBranch)1 OpenRepo (com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo)1 ArrayList (java.util.ArrayList)1