Add SubmitRequirement to hold the presubmit conditions not met

Currently, labels are (mis-) used to communicate with the user regarding
the presubmit failure reason. This leads to weird situations where the
Gerrit interface tells "Needs labels: Not-Author-Review,
CI-Build-Failure" which are not labels (and don't look like labels).

The introduced class and variable, SubmitRequirement, contains two
fields describing the issue and an optional label. This allows to
implement the two former examples: the CI doesn't need a label, but the
Non-Author review condition might be related to a Verified label, for
instance.

Change-Id: I83ab3fe52cc689416a26f9d4f91ebafb7337d428
This commit is contained in:
Maxime Guerreiro
2018-02-28 14:33:18 +01:00
parent 05af76fa4b
commit 227eb5776f
9 changed files with 212 additions and 6 deletions

View File

@@ -14,6 +14,10 @@
package com.google.gerrit.server.data;
/**
* Represents a {@link com.google.gerrit.common.data.SubmitRecord.Label} that does not depend on
* Gerrit internal classes, to be serialized.
*/
public class SubmitLabelAttribute {
public String label;
public String status;

View File

@@ -16,7 +16,12 @@ package com.google.gerrit.server.data;
import java.util.List;
/**
* Represents a {@link com.google.gerrit.common.data.SubmitRecord} that does not depend on Gerrit
* internal classes, to be serialized.
*/
public class SubmitRecordAttribute {
public String status;
public List<SubmitLabelAttribute> labels;
public List<SubmitRequirementAttribute> requirements;
}

View File

@@ -0,0 +1,25 @@
// 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.data;
/**
* Represents a {@link com.google.gerrit.common.data.SubmitRequirement} that does not depend on
* Gerrit internal classes, to be serialized
*/
public class SubmitRequirementAttribute {
public String shortReason;
public String fullReason;
public String label;
}