Merge changes I29e412b8,I57161c14
* changes: Make InvalidRevisionException a static class of CreateBranch AccountVisibilityProvider: Remove support for legacy suggest.accounts
This commit is contained in:
@@ -3655,23 +3655,6 @@ Set to 0 to disable this check.
|
||||
[[suggest]]
|
||||
=== Section suggest
|
||||
|
||||
[[suggest.accounts]]suggest.accounts::
|
||||
+
|
||||
If `true`, visible user accounts (according to the value of
|
||||
`accounts.visibility`) will be offered as completion suggestions
|
||||
when adding a reviewer to a change, or a user to a group.
|
||||
+
|
||||
If `false`, account suggestion is disabled.
|
||||
+
|
||||
Older configurations may also have one of the `accounts.visibility`
|
||||
values for this field, including `OFF` as a synonym for `NONE`. If
|
||||
`accounts.visibility` is also set, that value overrides this one;
|
||||
otherwise, this value applies to both `suggest.accounts` and
|
||||
`accounts.visibility`.
|
||||
+
|
||||
New configurations should prefer the boolean value for this field
|
||||
and an enum value for `accounts.visibility`.
|
||||
|
||||
[[suggest.maxSuggestedReviewers]]suggest.maxSuggestedReviewers::
|
||||
+
|
||||
The maximum numbers of reviewers suggested.
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "suggest.accounts", value = "false")
|
||||
@GerritConfig(name = "accounts.visibility", value = "NONE")
|
||||
public void suggestReviewersNoResult1() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
List<SuggestedReviewerInfo> reviewers =
|
||||
@@ -80,8 +80,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
@GerritConfigs(
|
||||
{@GerritConfig(name = "suggest.accounts", value = "true"),
|
||||
@GerritConfig(name = "suggest.from", value = "1"),
|
||||
{@GerritConfig(name = "suggest.from", value = "1"),
|
||||
@GerritConfig(name = "accounts.visibility", value = "NONE")
|
||||
})
|
||||
public void suggestReviewersNoResult2() throws Exception {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.common.errors;
|
||||
|
||||
/** Error indicating the revision is invalid as supplied. */
|
||||
public class InvalidRevisionException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String MESSAGE = "Invalid Revision";
|
||||
|
||||
public InvalidRevisionException() {
|
||||
super(MESSAGE);
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,8 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AccountVisibilityProvider implements Provider<AccountVisibility> {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(AccountVisibilityProvider.class);
|
||||
|
||||
private final AccountVisibility accountVisibility;
|
||||
|
||||
@Inject
|
||||
@@ -33,19 +28,6 @@ public class AccountVisibilityProvider implements Provider<AccountVisibility> {
|
||||
AccountVisibility av;
|
||||
if (cfg.getString("accounts", null, "visibility") != null) {
|
||||
av = cfg.getEnum("accounts", null, "visibility", AccountVisibility.ALL);
|
||||
} else if (cfg.getString("suggest", null, "accounts") != null) {
|
||||
try {
|
||||
av = cfg.getEnum("suggest", null, "accounts", AccountVisibility.ALL);
|
||||
log.warn(String.format(
|
||||
"Using legacy value %s for suggest.accounts;"
|
||||
+ " use accounts.visibility=%s instead",
|
||||
av, av));
|
||||
} catch (IllegalArgumentException err) {
|
||||
// If suggest.accounts is a valid boolean, it's a new-style config, and
|
||||
// we should use the default here. Invalid values are caught in
|
||||
// SuggestServiceImpl so we don't worry about them here.
|
||||
av = AccountVisibility.ALL;
|
||||
}
|
||||
} else {
|
||||
av = AccountVisibility.ALL;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
import com.google.gerrit.common.errors.InvalidRevisionException;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInfo;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -253,4 +252,15 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
|
||||
throw new InvalidRevisionException();
|
||||
}
|
||||
}
|
||||
|
||||
/** Error indicating the revision is invalid as supplied. */
|
||||
private static class InvalidRevisionException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String MESSAGE = "Invalid Revision";
|
||||
|
||||
public InvalidRevisionException() {
|
||||
super(MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user