LCOV - code coverage report
Current view: top level - server/patch - MergeListBuilder.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 13 15 86.7 %
Date: 2022-11-19 15:00:39 Functions: 1 2 50.0 %

          Line data    Source code
       1             : // Copyright (C) 2016 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.patch;
      16             : 
      17             : import com.google.common.collect.ImmutableList;
      18             : import java.io.IOException;
      19             : import org.eclipse.jgit.revwalk.RevCommit;
      20             : import org.eclipse.jgit.revwalk.RevWalk;
      21             : 
      22           0 : public class MergeListBuilder {
      23             :   public static ImmutableList<RevCommit> build(RevWalk rw, RevCommit merge, int uninterestingParent)
      24             :       throws IOException {
      25          31 :     rw.reset();
      26          31 :     rw.parseBody(merge);
      27          31 :     if (merge.getParentCount() < 2) {
      28           0 :       return ImmutableList.of();
      29             :     }
      30             : 
      31          31 :     for (int parent = 0; parent < merge.getParentCount(); parent++) {
      32          31 :       RevCommit parentCommit = merge.getParent(parent);
      33          31 :       rw.parseBody(parentCommit);
      34          31 :       if (parent == uninterestingParent - 1) {
      35          31 :         rw.markUninteresting(parentCommit);
      36             :       } else {
      37          31 :         rw.markStart(parentCommit);
      38             :       }
      39             :     }
      40             : 
      41          31 :     ImmutableList.Builder<RevCommit> result = ImmutableList.builder();
      42             :     RevCommit c;
      43          31 :     while ((c = rw.next()) != null) {
      44          31 :       result.add(c);
      45             :     }
      46          31 :     return result.build();
      47             :   }
      48             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750