Search in sources :

Example 1 with ChangeIsVisibleToPredicate

use of com.google.gerrit.server.query.change.ChangeIsVisibleToPredicate in project gerrit by GerritCodeReview.

the class LocalMergeSuperSetComputation method byCommitsOnBranchNotMerged.

@UsedAt(UsedAt.Project.GOOGLE)
public ChangeSet byCommitsOnBranchNotMerged(OpenRepo or, BranchNameKey branch, Set<String> visibleHashes, Set<String> nonVisibleHashes, CurrentUser user) throws IOException {
    List<ChangeData> potentiallyVisibleChanges = byCommitsOnBranchNotMerged(or, branch, visibleHashes);
    List<ChangeData> invisibleChanges = new ArrayList<>(byCommitsOnBranchNotMerged(or, branch, nonVisibleHashes));
    List<ChangeData> visibleChanges = new ArrayList<>(potentiallyVisibleChanges.size());
    ChangeIsVisibleToPredicate changeIsVisibleToPredicate = changeIsVisibleToPredicateFactory.forUser(user);
    for (ChangeData cd : potentiallyVisibleChanges) {
        // permissions (except for private changes).
        if (!cd.change().isPrivate() || changeIsVisibleToPredicate.match(cd)) {
            visibleChanges.add(cd);
        } else {
            invisibleChanges.add(cd);
        }
    }
    return new ChangeSet(visibleChanges, invisibleChanges);
}
Also used : ChangeIsVisibleToPredicate(com.google.gerrit.server.query.change.ChangeIsVisibleToPredicate) ArrayList(java.util.ArrayList) ChangeData(com.google.gerrit.server.query.change.ChangeData) UsedAt(com.google.gerrit.common.UsedAt)

Aggregations

UsedAt (com.google.gerrit.common.UsedAt)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1 ChangeIsVisibleToPredicate (com.google.gerrit.server.query.change.ChangeIsVisibleToPredicate)1 ArrayList (java.util.ArrayList)1