Expose index.change.mergeable in ServerInfo

This commit exposes indexMergeable in ServerInfo to allow the UI to hide
the 'is:mergeable' operator conditionally if the Gerrit instance does
not support indexing the 'mergeable' bit.

Change-Id: I1959244ff0069d0368bbee1fc8a527c3f3b2b0b2
This commit is contained in:
Patrick Hiesel
2019-12-02 17:23:24 +01:00
parent 5c657aa0d6
commit bc3addc409
6 changed files with 94 additions and 0 deletions

View File

@@ -1572,6 +1572,21 @@ configuration parameter] that controls whether the mergeability bit in
link:rest-api-changes.html#change-info[ChangeInfo] will never be set.
|=============================
[[change-index-config-info]]
=== ChangeIndexConfigInfo
The `ChangeIndexConfigInfo` entity contains information about Gerrit
configuration from the link:config-gerrit.html#index.change[index.change]
section.
[options="header",cols="1,^1,5"]
|=============================
|Field Name ||Description
|`index_mergeable` |not set if `false`|
Value of the link:config-gerrit.html#index.change.indexMergeable[
configuration parameter] that controls whether the mergeability bit is
indexed (hence queryable using `is:mergeable`).
|=============================
[[check-account-external-ids-input]]
=== CheckAccountExternalIdsInput
The `CheckAccountExternalIdsInput` entity contains input for the
@@ -1821,6 +1836,21 @@ Whether to enable the web UI for editing GPG keys.
link:config-gerrit.html#gerrit.reportBugUrl[URL to report bugs].
|=================================
[[index-config-info]]
=== IndexConfigInfo
The `IndexConfigInfo` entity contains information about Gerrit
configuration from the link:config-gerrit.html#index[index]
section.
[options="header",cols="1,^1,5"]
|=============================
|Field Name ||Description
|`change` ||
Information about the configuration from the
link:config-gerrit.html#index.change[index.change] section as
link:#index.change[ChangeIndexConfigInfo] entity.
|=============================
[[hit-ration-info]]
=== HitRatioInfo
The `HitRatioInfo` entity contains information about the hit ratio of a
@@ -1947,6 +1977,10 @@ information about Gerrit
Information about the configuration from the
link:config-gerrit.html#gerrit[gerrit] section as link:#gerrit-info[
GerritInfo] entity.
|`index` ||
Information about the configuration from the
link:config-gerrit.html#index[index] section as link:#index[
IndexConfigInfo] entity.
|`note_db_enabled` |not set if `false`|
Whether the NoteDb storage backend is fully enabled.
|`plugin` ||

View File

@@ -0,0 +1,19 @@
// Copyright (C) 2019 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.extensions.common;
public class ChangeIndexConfigInfo {
public Boolean indexMergeable;
}

View File

@@ -0,0 +1,19 @@
// Copyright (C) 2019 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.extensions.common;
public class IndexConfigInfo {
public ChangeIndexConfigInfo change;
}

View File

@@ -20,6 +20,7 @@ public class ServerInfo {
public ChangeConfigInfo change;
public DownloadInfo download;
public GerritInfo gerrit;
public IndexConfigInfo index;
public Boolean noteDbEnabled;
public PluginConfigInfo plugin;
public SshdInfo sshd;

View File

@@ -23,9 +23,11 @@ import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gerrit.extensions.common.AccountsInfo;
import com.google.gerrit.extensions.common.AuthInfo;
import com.google.gerrit.extensions.common.ChangeConfigInfo;
import com.google.gerrit.extensions.common.ChangeIndexConfigInfo;
import com.google.gerrit.extensions.common.DownloadInfo;
import com.google.gerrit.extensions.common.DownloadSchemeInfo;
import com.google.gerrit.extensions.common.GerritInfo;
import com.google.gerrit.extensions.common.IndexConfigInfo;
import com.google.gerrit.extensions.common.PluginConfigInfo;
import com.google.gerrit.extensions.common.ReceiveInfo;
import com.google.gerrit.extensions.common.ServerInfo;
@@ -141,6 +143,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
info.change = getChangeInfo();
info.download = getDownloadInfo();
info.gerrit = getGerritInfo();
info.index = getIndexInfo();
info.noteDbEnabled = true;
info.plugin = getPluginInfo();
info.defaultTheme = getDefaultTheme();
@@ -296,6 +299,14 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
return info;
}
private IndexConfigInfo getIndexInfo() {
ChangeIndexConfigInfo change = new ChangeIndexConfigInfo();
change.indexMergeable = toBoolean(config.getBoolean("index", "change", "indexMergeable", true));
IndexConfigInfo index = new IndexConfigInfo();
index.change = change;
return index;
}
private String getDocUrl() {
String docUrl = config.getString("gerrit", null, "docUrl");
if (Strings.isNullOrEmpty(docUrl)) {

View File

@@ -180,6 +180,9 @@ public class ServerInfoIT extends AbstractDaemonTest {
assertThat(i.gerrit.allUsers).isEqualTo(AllUsersNameProvider.DEFAULT);
assertThat(i.gerrit.reportBugUrl).isNull();
// index
assertThat(i.index.change.indexMergeable).isNull(); // false in all tests
// plugin
assertThat(i.plugin.jsResourcePaths).isEmpty();
@@ -206,4 +209,11 @@ public class ServerInfoIT extends AbstractDaemonTest {
ServerInfo i = gApi.config().server().getInfo();
assertThat(i.change.excludeMergeableInChangeInfo).isTrue();
}
@Test
@GerritConfig(name = "index.change.indexMergeable", value = "true")
public void indexMergeableIsTrueWhenTrueInConfig() throws Exception {
ServerInfo i = gApi.config().server().getInfo();
assertThat(i.index.change.indexMergeable).isTrue();
}
}