Merge branch 'stable-3.1' into stable-3.2
* stable-3.1: Update git submodules Update git submodules Update git submodules Update git submodules Update git submodules Update git submodules Update git submodules Update git submodules Fix 'visibleto' predicate for group Upgrade recommended version of buildifier to 3.0.0 Update git submodules Update git submodules Update git submodules Change-Id: I95c5ea380a7135aadf5713fd4ec5772adb77a0c7
This commit is contained in:
@@ -116,7 +116,7 @@ To format Java source code, Gerrit uses the
|
||||
link:https://github.com/google/google-java-format[`google-java-format`,role=external,window=_blank]
|
||||
tool (version 1.7), and to format Bazel BUILD, WORKSPACE and .bzl files the
|
||||
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`,role=external,window=_blank]
|
||||
tool (version 2.0.0). Unused dependencies are found and removed using the
|
||||
tool (version 3.0.0). Unused dependencies are found and removed using the
|
||||
link:https://github.com/bazelbuild/buildtools/tree/master/unused_deps[`unused_deps`,role=external,window=_blank]
|
||||
build tool, a sibling of `buildifier`.
|
||||
|
||||
|
||||
@@ -86,7 +86,10 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData>
|
||||
PermissionBackend.WithUser withUser =
|
||||
user.isIdentifiedUser()
|
||||
? permissionBackend.absentUser(user.getAccountId())
|
||||
: permissionBackend.user(anonymousUserProvider.get());
|
||||
: permissionBackend.user(
|
||||
Optional.of(user)
|
||||
.filter(u -> u instanceof SingleGroupUser)
|
||||
.orElseGet(anonymousUserProvider::get));
|
||||
try {
|
||||
withUser.indexedChange(cd, notes).check(ChangePermission.READ);
|
||||
} catch (PermissionBackendException e) {
|
||||
|
||||
@@ -44,8 +44,13 @@ import com.google.common.truth.ThrowableSubject;
|
||||
import com.google.gerrit.acceptance.config.GerritConfig;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.entities.AccountGroup;
|
||||
import com.google.gerrit.entities.BranchNameKey;
|
||||
import com.google.gerrit.entities.Change;
|
||||
import com.google.gerrit.entities.Patch;
|
||||
@@ -123,6 +128,7 @@ import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -133,6 +139,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectInserter;
|
||||
@@ -1791,6 +1799,18 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
|
||||
String g1 = createGroup("group1", "Administrators");
|
||||
gApi.groups().id(g1).addMembers("user2");
|
||||
|
||||
// By default when a group is created without any permission granted,
|
||||
// nothing is visible to it; having members or not has nothing to do with it
|
||||
assertQuery(q + " visibleto:" + g1);
|
||||
|
||||
// change is visible to group ONLY when access is granted
|
||||
grant(
|
||||
Project.nameKey("repo"),
|
||||
"refs/*",
|
||||
Permission.READ,
|
||||
false,
|
||||
AccountGroup.uuid(gApi.groups().id(g1).get().id));
|
||||
assertQuery(q + " visibleto:" + g1, change1);
|
||||
|
||||
requestContext.setContext(newRequestContext(user2));
|
||||
@@ -1824,6 +1844,26 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
q + " visibleto:\"Another User\"", "\"Another User\" resolves to multiple accounts");
|
||||
}
|
||||
|
||||
protected void grant(
|
||||
Project.NameKey project,
|
||||
String ref,
|
||||
String permission,
|
||||
boolean force,
|
||||
AccountGroup.UUID groupUUID)
|
||||
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
|
||||
md.setMessage(String.format("Grant %s on %s", permission, ref));
|
||||
ProjectConfig config = projectConfigFactory.read(md);
|
||||
AccessSection s = config.getAccessSection(ref, true);
|
||||
Permission p = s.getPermission(permission, true);
|
||||
PermissionRule rule = new PermissionRule(new GroupReference(groupUUID, groupUUID.get()));
|
||||
rule.setForce(force);
|
||||
p.add(rule);
|
||||
config.commit(md);
|
||||
projectCache.evict(config.getProject());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void visibleToSelf() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
|
||||
Reference in New Issue
Block a user