Merge branch 'stable-3.1'
* stable-3.1: Update git submodules Update git submodules gr-rest-api-interface.js: Remove unnecesary Promise resolution LuceneQueryChangesTest: Remove unneeded override of visible() e2e-tests: Rename the now reused json filename constant e2e-tests: Refactor documentation about functional RevisionActions: Do not alter server response e2e-tests: Move core json files into scala package e2e-tests: Support adding/running non-core scenarios e2e-tests: Add create/delete project to CloneUsingBothProtocols ChangeQueryBuilder: Throw error on ambiguous visibleto by display name Change-Id: Idbb499461ecad11da49b3bcbe5d5bf14e90bfe31
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.query.change;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.gerrit.entities.Change.CHANGE_ID_PATTERN;
|
||||
import static com.google.gerrit.server.account.AccountResolver.isSelf;
|
||||
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
|
||||
@@ -24,6 +23,7 @@ import static java.util.stream.Collectors.toSet;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.primitives.Ints;
|
||||
@@ -985,18 +985,23 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData, ChangeQueryBuil
|
||||
if (isSelf(who)) {
|
||||
return isVisible();
|
||||
}
|
||||
Set<Account.Id> accounts = null;
|
||||
try {
|
||||
return Predicate.or(
|
||||
parseAccount(who).stream()
|
||||
.map(a -> visibleto(args.userFactory.create(a)))
|
||||
.collect(toImmutableList()));
|
||||
accounts = parseAccount(who);
|
||||
} catch (QueryParseException e) {
|
||||
if (e instanceof QueryRequiresAuthException) {
|
||||
throw e;
|
||||
}
|
||||
// Otherwise continue: if it's not an account, maybe it's a group?
|
||||
}
|
||||
if (accounts != null) {
|
||||
if (accounts.size() == 1) {
|
||||
return visibleto(args.userFactory.create(Iterables.getOnlyElement(accounts)));
|
||||
} else if (accounts.size() > 1) {
|
||||
throw error(String.format("\"%s\" resolves to multiple accounts", who));
|
||||
}
|
||||
}
|
||||
|
||||
// If its not an account, maybe its a group?
|
||||
Collection<GroupReference> suggestions = args.groupBackend.suggest(who, null);
|
||||
if (!suggestions.isEmpty()) {
|
||||
HashSet<AccountGroup.UUID> ids = new HashSet<>();
|
||||
|
||||
Reference in New Issue
Block a user