Return changes from mergeable in ChangeJson only if tested
If background mergeability checks are not working for some reason, we should not blindly report that changes are unmergeable. We have enough information stored in the change, namely the last SHA-1 tested against, to know whether a check was ever successfully run. Take advantage of this in ChangeJson. Change-Id: I4df800d66ac929e9cd152795acd9f5b671bfd101
This commit is contained in:
@@ -2808,7 +2808,7 @@ Whether the change was reviewed by the calling user.
|
||||
Only set if link:#reviewed[reviewed] is requested.
|
||||
|`mergeable` |optional|
|
||||
Whether the change is mergeable. +
|
||||
Not set for merged changes.
|
||||
Not set for merged changes, or if the change has not yet been tested.
|
||||
|`insertions` ||
|
||||
Number of inserted lines.
|
||||
|`deletions` ||
|
||||
|
@@ -267,7 +267,7 @@ public class ChangeJson {
|
||||
out.branch = in.getDest().getShortName();
|
||||
out.topic = in.getTopic();
|
||||
out.changeId = in.getKey().get();
|
||||
out.mergeable = in.getStatus() != Change.Status.MERGED ? in.isMergeable() : null;
|
||||
out.mergeable = isMergeable(in);
|
||||
ChangedLines changedLines = cd.changedLines();
|
||||
if (changedLines != null) {
|
||||
out.insertions = changedLines.insertions;
|
||||
@@ -330,6 +330,14 @@ public class ChangeJson {
|
||||
return out;
|
||||
}
|
||||
|
||||
private Boolean isMergeable(Change c) {
|
||||
if (c.getStatus() == Change.Status.MERGED
|
||||
|| c.getLastSha1MergeTested() == null) {
|
||||
return null;
|
||||
}
|
||||
return c.isMergeable();
|
||||
}
|
||||
|
||||
private List<SubmitRecord> submitRecords(ChangeControl ctl, ChangeData cd)
|
||||
throws OrmException {
|
||||
if (cd.getSubmitRecords() != null) {
|
||||
|
Reference in New Issue
Block a user