SuggestReviewer: Support reloaded config
SuggestReviewer will automatically pickup the reloaded config, however we want to notify the admin that issued the reload, that these config values has changed and will be picked up. Change-Id: I879d40b3c10856598726e46dc455d702e008139f
This commit is contained in:
@@ -127,6 +127,9 @@ Default is 10.
|
||||
This setting only applies for adding reviewers in the Gerrit Web UI,
|
||||
but is ignored when adding reviewers with the
|
||||
link:cmd-set-reviewers.html[set-reviewers] command.
|
||||
+
|
||||
This value supports configuration reloads:
|
||||
link:cmd-reload-config.html[reload-config]
|
||||
|
||||
[[addreviewer.maxAllowed]]addreviewer.maxAllowed::
|
||||
+
|
||||
@@ -137,6 +140,9 @@ If set to 0, there is no limit for the number of reviewers that can
|
||||
be added at once by adding a group as reviewer.
|
||||
+
|
||||
Default is 20.
|
||||
+
|
||||
This value supports configuration reloads:
|
||||
link:cmd-reload-config.html[reload-config]
|
||||
|
||||
[[addReviewer.baseWeight]]addReviewer.baseWeight::
|
||||
+
|
||||
@@ -4558,6 +4564,9 @@ Set to 0 to disable this check.
|
||||
The maximum numbers of reviewers suggested.
|
||||
+
|
||||
By default 10.
|
||||
+
|
||||
This value supports configuration reloads:
|
||||
link:cmd-reload-config.html[reload-config]
|
||||
|
||||
[[suggest.from]]suggest.from::
|
||||
+
|
||||
|
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2018 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.server.config;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Collections;
|
||||
|
||||
public class GerritConfigListenerHelper {
|
||||
public static GerritConfigListener acceptIfChanged(ConfigKey... keys) {
|
||||
return e ->
|
||||
e.isEntriesUpdated(ImmutableSet.copyOf(keys))
|
||||
? Collections.singletonList(e.accept(ImmutableSet.copyOf(keys)))
|
||||
: Collections.emptyList();
|
||||
}
|
||||
}
|
@@ -169,6 +169,7 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryProcessor;
|
||||
import com.google.gerrit.server.query.change.ConflictsCacheImpl;
|
||||
import com.google.gerrit.server.restapi.change.SuggestReviewers;
|
||||
import com.google.gerrit.server.restapi.config.ConfigRestModule;
|
||||
import com.google.gerrit.server.restapi.group.GroupModule;
|
||||
import com.google.gerrit.server.rules.DefaultSubmitRule;
|
||||
@@ -372,6 +373,8 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
DynamicMap.mapOf(binder(), DownloadCommand.class);
|
||||
DynamicMap.mapOf(binder(), CloneCommand.class);
|
||||
DynamicMap.mapOf(binder(), ReviewerSuggestion.class);
|
||||
DynamicSet.bind(binder(), GerritConfigListener.class)
|
||||
.toInstance(SuggestReviewers.configListener());
|
||||
DynamicSet.setOf(binder(), ExternalIncludedIn.class);
|
||||
DynamicMap.mapOf(binder(), ProjectConfigEntry.class);
|
||||
DynamicSet.setOf(binder(), PatchSetWebLink.class);
|
||||
|
@@ -14,9 +14,13 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.gerrit.server.config.GerritConfigListenerHelper.acceptIfChanged;
|
||||
|
||||
import com.google.gerrit.extensions.common.AccountVisibility;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.config.ConfigKey;
|
||||
import com.google.gerrit.server.config.GerritConfigListener;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -104,4 +108,12 @@ public class SuggestReviewers {
|
||||
"maxWithoutConfirmation",
|
||||
PostReviewers.DEFAULT_MAX_REVIEWERS_WITHOUT_CHECK);
|
||||
}
|
||||
|
||||
public static GerritConfigListener configListener() {
|
||||
return acceptIfChanged(
|
||||
ConfigKey.create("suggest", "maxSuggestedReviewers"),
|
||||
ConfigKey.create("suggest", "accounts"),
|
||||
ConfigKey.create("addreviewer", "maxAllowed"),
|
||||
ConfigKey.create("addreviewer", "maxWithoutConfirmation"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user