Merge "Allow reset start and finish time of checks."
diff --git a/java/com/google/gerrit/plugins/checks/CheckJson.java b/java/com/google/gerrit/plugins/checks/CheckJson.java
index e4199e9..074d4cc 100644
--- a/java/com/google/gerrit/plugins/checks/CheckJson.java
+++ b/java/com/google/gerrit/plugins/checks/CheckJson.java
@@ -89,6 +89,7 @@
info.checkerName = checker.getName().orElse(null);
info.checkerStatus = checker.getStatus();
info.blocking = checker.getBlockingConditions();
+ info.checkerDescription = checker.getDescription().orElse(null);
});
} catch (ConfigInvalidException e) {
logger.atWarning().withCause(e).log("skipping invalid checker %s", checkerUuid);
diff --git a/java/com/google/gerrit/plugins/checks/acceptance/AbstractCheckersTest.java b/java/com/google/gerrit/plugins/checks/acceptance/AbstractCheckersTest.java
index e476537..51fcc41 100644
--- a/java/com/google/gerrit/plugins/checks/acceptance/AbstractCheckersTest.java
+++ b/java/com/google/gerrit/plugins/checks/acceptance/AbstractCheckersTest.java
@@ -38,7 +38,7 @@
sysModule = "com.google.gerrit.plugins.checks.acceptance.TestModule",
httpModule = "com.google.gerrit.plugins.checks.HttpModule")
public class AbstractCheckersTest extends LightweightPluginDaemonTest {
- @Inject protected ProjectOperations projectOperations;
+ @Inject private ProjectOperations projectOperations;
protected CheckerOperations checkerOperations;
protected CheckOperations checkOperations;
diff --git a/java/com/google/gerrit/plugins/checks/api/CheckInfo.java b/java/com/google/gerrit/plugins/checks/api/CheckInfo.java
index 77cbdef..d0d5c38 100644
--- a/java/com/google/gerrit/plugins/checks/api/CheckInfo.java
+++ b/java/com/google/gerrit/plugins/checks/api/CheckInfo.java
@@ -56,6 +56,9 @@
/** Blocking conditions that apply to this check. */
public Set<BlockingCondition> blocking;
+ /** Description of the checker that produced this check */
+ public String checkerDescription;
+
@Override
public boolean equals(Object o) {
if (!(o instanceof CheckInfo)) {
@@ -75,7 +78,8 @@
&& Objects.equals(other.updated, updated)
&& Objects.equals(other.checkerName, checkerName)
&& Objects.equals(other.checkerStatus, checkerStatus)
- && Objects.equals(other.blocking, blocking);
+ && Objects.equals(other.blocking, blocking)
+ && Objects.equals(other.checkerDescription, checkerDescription);
}
@Override
@@ -94,7 +98,8 @@
updated,
checkerName,
checkerStatus,
- blocking);
+ blocking,
+ checkerDescription);
}
@Override
@@ -114,6 +119,7 @@
.add("checkerName", checkerName)
.add("checkerStatus", checkerStatus)
.add("blocking", blocking)
+ .add("checkerDescription", checkerDescription)
.toString();
}
}
diff --git a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
index 61bd436..3adb2dd 100644
--- a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
+++ b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
@@ -28,7 +28,6 @@
import com.google.gerrit.plugins.checks.Checkers;
import com.google.gerrit.plugins.checks.CheckersUpdate;
import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.git.meta.VersionedMetaData;
import com.google.gerrit.server.util.time.TimeUtil;
@@ -152,7 +151,8 @@
* @throws IOException if the repository can't be accessed for some reason
* @throws ConfigInvalidException if the checker exists but can't be read due to an invalid format
*/
- public static CheckerConfig loadForChecker(NameKey projectName, Repository repository, Ref ref)
+ public static CheckerConfig loadForChecker(
+ Project.NameKey projectName, Repository repository, Ref ref)
throws IOException, ConfigInvalidException {
CheckerConfig checkerConfig = new CheckerConfig(ref.getName());
checkerConfig.load(projectName, repository);
diff --git a/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java b/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
index 02847e8..0d97576 100644
--- a/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
+++ b/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
@@ -34,9 +34,7 @@
import com.google.gerrit.plugins.checks.api.CombinedCheckState;
import com.google.gerrit.plugins.checks.api.CombinedCheckState.CheckStateCount;
import com.google.gerrit.reviewdb.client.PatchSet;
-import com.google.gerrit.reviewdb.client.PatchSet.Id;
import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -131,15 +129,15 @@
}
@Override
- public CombinedCheckState getCombinedCheckState(NameKey projectName, Id patchSetId)
- throws IOException, StorageException {
+ public CombinedCheckState getCombinedCheckState(
+ Project.NameKey projectName, PatchSet.Id patchSetId) throws IOException, StorageException {
ImmutableListMultimap<CheckState, Boolean> statesAndRequired =
getStatesAndRequiredMap(projectName, patchSetId);
return CombinedCheckState.combine(statesAndRequired);
}
@Override
- public boolean areAllRequiredCheckersPassing(NameKey projectName, Id patchSetId)
+ public boolean areAllRequiredCheckersPassing(Project.NameKey projectName, PatchSet.Id patchSetId)
throws IOException, StorageException {
ImmutableListMultimap<CheckState, Boolean> statesAndRequired =
getStatesAndRequiredMap(projectName, patchSetId);
@@ -149,7 +147,7 @@
}
private ImmutableListMultimap<CheckState, Boolean> getStatesAndRequiredMap(
- NameKey projectName, Id patchSetId) throws IOException, StorageException {
+ Project.NameKey projectName, PatchSet.Id patchSetId) throws IOException, StorageException {
ChangeData changeData = changeDataFactory.create(projectName, patchSetId.changeId());
ImmutableMap<String, Checker> allCheckersOfProject =
checkers.checkersOf(projectName).stream()
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
index ee4b51f..71d468d 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
@@ -24,6 +24,7 @@
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SkipProjectClone;
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.client.ChangeStatus;
import com.google.gerrit.extensions.common.ChangeInput;
@@ -51,6 +52,7 @@
@SkipProjectClone
public class CheckerRefsIT extends AbstractCheckersTest {
+ @Inject private ProjectOperations projectOperations;
@Inject private Sequences seq;
@Inject private ChangeInserter.Factory changeInserterFactory;
@Inject private BatchUpdate.Factory updateFactory;
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
index 9e2a066..ecd2596 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
@@ -89,7 +89,12 @@
@Test
public void getCheckWithOptions() throws Exception {
CheckerUuid checkerUuid =
- checkerOperations.newChecker().repository(project).name("My Checker").create();
+ checkerOperations
+ .newChecker()
+ .repository(project)
+ .name("My Checker")
+ .description("Description")
+ .create();
CheckKey checkKey = CheckKey.create(project, patchSetId, checkerUuid);
checkOperations.newCheck(checkKey).state(CheckState.RUNNING).upsert();
@@ -99,7 +104,7 @@
expectedCheckInfo.checkerName = "My Checker";
expectedCheckInfo.checkerStatus = CheckerStatus.ENABLED;
expectedCheckInfo.blocking = ImmutableSortedSet.of();
-
+ expectedCheckInfo.checkerDescription = "Description";
assertThat(getCheckInfo(patchSetId, checkerUuid, ListChecksOption.CHECKER))
.isEqualTo(expectedCheckInfo);
}
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
index 5bfbee0..2727203 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
@@ -23,6 +23,7 @@
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.RestResponse;
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -50,6 +51,7 @@
import org.junit.Test;
public class QueryPendingChecksIT extends AbstractCheckersTest {
+ @Inject private ProjectOperations projectOperations;
@Inject private RequestScopeOperations requestScopeOperations;
private PatchSet.Id patchSetId;
diff --git a/resources/Documentation/rest-api-checkers.md b/resources/Documentation/rest-api-checkers.md
index 40e1cf3..f05816f 100644
--- a/resources/Documentation/rest-api-checkers.md
+++ b/resources/Documentation/rest-api-checkers.md
@@ -49,7 +49,7 @@
Creates a new checker.
In the request body the data for the checker must be provided as a
-[CheckerInput](#checker-input) entity.
+[CheckerCreateInput](#checker-create-input) entity.
Note that only users with the [Administrate
Checkers](access-control.md#capability_administrateCheckers) global capability
@@ -94,12 +94,12 @@
Updates a checker.
The new property values must be set in the request body in a
-[CheckerInput](#checker-input) entity.
+[CheckerUpdateInput](#checker-update-input) entity.
This REST endpoint supports partial updates of the checker property set. Only
-properties that are set in the [CheckerInput](#checker-input) entity are
-updated. Properties that are not set in the input (or that have `null` as value)
-are not touched.
+properties that are set in the [CheckerUpdateInput](#checker-update-input)
+entity are updated. Properties that are not set in the input (or that have
+`null` as value) are not touched.
Unsetting properties:
@@ -174,6 +174,20 @@
## <a id="json-entities"> JSON Entities
+### <a id="checker-create-input"> CheckerCreateInput
+The `CheckerCreateInput` entity contains information for creating a checker.
+
+| Field Name | | Description |
+| --------------- | -------- | ----------- |
+| `uuid` | | The [UUID](#checker-id) of the checker.
+| `name` | | The name of the checker.
+| `description` | optional | The description of the checker.
+| `url` | optional | The URL of the checker.
+| `repository` | | The (exact) name of the repository for which the checker applies.
+| `status` | optional | The status of the checker; one of `ENABLED` or `DISABLED`.
+| `blocking` | optional | A list of [conditions](#blocking-conditions) that describe when the checker should block change submission.
+| `query` | optional | A [query](#query) that limits changes for which the checker is relevant.
+
### <a id="checker-info"> CheckerInfo
The `CheckerInfo` entity describes a checker.
@@ -190,12 +204,12 @@
| `created` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the checker was created.
| `updated` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the checker was last updated.
-### <a id="checker-input"> CheckerInput
-The `CheckerInput` entity contains information for creating a checker.
+### <a id="checker-update-input"> CheckerUpdateInput
+The `CheckerUpdateInput` entity contains information for updating a checker.
| Field Name | | Description |
| --------------- | -------- | ----------- |
-| `name` | optional | The name of the checker. Must be specified for checker creation.
+| `name` | optional | The name of the checker.
| `description` | optional | The description of the checker.
| `url` | optional | The URL of the checker.
| `repository` | optional | The (exact) name of the repository for which the checker applies.
diff --git a/resources/Documentation/rest-api-checks.md b/resources/Documentation/rest-api-checks.md
index b34ed31..4bcd1a1 100644
--- a/resources/Documentation/rest-api-checks.md
+++ b/resources/Documentation/rest-api-checks.md
@@ -161,22 +161,23 @@
### <a id="check-info"> CheckInfo
The `CheckInfo` entity describes a check.
-| Field Name | | Description |
-| ----------------- | -------- | ----------- |
-| `repository` | | The repository name that this check applies to.
-| `change_number` | | The change number that this check applies to.
-| `patch_set_id` | | The patch set that this check applies to.
-| `checker_uuid` | | The [UUID](./rest-api-checkers.md#checker-id) of the checker that reported this check.
-| `state` | | The state as string-serialized form of [CheckState](#check-state)
-| `message` | optional | Short message explaining the check state.
-| `url` | optional | A fully-qualified URL pointing to the result of the check on the checker's infrastructure.
-| `started` | optional | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check started processing.
-| `finished` | optional | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check finished processing.
-| `created` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check was created.
-| `updated` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check was last updated.
-| `checker_name` | optional | The name of the checker that produced this check.<br />Only set if [checker details](#option-checker) are requested.
-| `checker_status` | optional | The [status](rest-api-checkers.md#checker-info) of the checker that produced this check.<br />Only set if [checker details](#option-checker) are requested.
-| `blocking` | optional | Set of [blocking conditions](rest-api-checkers.md#blocking-conditions) that apply to this checker.<br />Only set if [checker details](#option-checker) are requested.
+| Field Name | | Description |
+| --------------------- | -------- | ----------- |
+| `repository` | | The repository name that this check applies to.
+| `change_number` | | The change number that this check applies to.
+| `patch_set_id` | | The patch set that this check applies to.
+| `checker_uuid` | | The [UUID](./rest-api-checkers.md#checker-id) of the checker that reported this check.
+| `state` | | The state as string-serialized form of [CheckState](#check-state)
+| `message` | optional | Short message explaining the check state.
+| `url` | optional | A fully-qualified URL pointing to the result of the check on the checker's infrastructure.
+| `started` | optional | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check started processing.
+| `finished` | optional | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check finished processing.
+| `created` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check was created.
+| `updated` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the check was last updated.
+| `checker_name` | optional | The name of the checker that produced this check.<br />Only set if [checker details](#option-checker) are requested.
+| `checker_status` | optional | The [status](rest-api-checkers.md#checker-info) of the checker that produced this check.<br />Only set if [checker details](#option-checker) are requested.
+| `blocking` | optional | Set of [blocking conditions](rest-api-checkers.md#blocking-conditions) that apply to this checker.<br />Only set if [checker details](#option-checker) are requested.
+| `checker_description` | optional | The description of the checker that reported this check.
### <a id="check-input"> CheckInput
The `CheckInput` entity contains information for creating or updating a check.