Merge "Omit change JSON fields when data is missing"
This commit is contained in:
@@ -248,7 +248,7 @@ public class ChangeJson {
|
||||
out.reviewed = in.getStatus().isOpen() && isChangeReviewed(cd) ? true : null;
|
||||
out.labels = labelsFor(cd, options.contains(LABELS),
|
||||
options.contains(DETAILED_LABELS));
|
||||
if (options.contains(DETAILED_LABELS)) {
|
||||
if (out.labels != null && options.contains(DETAILED_LABELS)) {
|
||||
out.permitted_labels = permittedLabels(cd);
|
||||
out.removable_reviewers = removableReviewers(cd, out.labels.values());
|
||||
}
|
||||
@@ -257,10 +257,12 @@ public class ChangeJson {
|
||||
if (options.contains(ALL_REVISIONS) || options.contains(CURRENT_REVISION)
|
||||
|| cd.getLimitedPatchSets() != null) {
|
||||
out.revisions = revisions(cd);
|
||||
for (String commit : out.revisions.keySet()) {
|
||||
if (out.revisions.get(commit).isCurrent) {
|
||||
out.current_revision = commit;
|
||||
break;
|
||||
if (out.revisions != null) {
|
||||
for (String commit : out.revisions.keySet()) {
|
||||
if (out.revisions.get(commit).isCurrent) {
|
||||
out.current_revision = commit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,12 +317,12 @@ public class ChangeJson {
|
||||
|
||||
ChangeControl ctl = control(cd);
|
||||
if (ctl == null) {
|
||||
return Collections.emptyMap();
|
||||
return null;
|
||||
}
|
||||
|
||||
PatchSet ps = cd.currentPatchSet(db);
|
||||
if (ps == null) {
|
||||
return Collections.emptyMap();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
@@ -553,7 +555,7 @@ public class ChangeJson {
|
||||
throws OrmException {
|
||||
ChangeControl ctl = control(cd);
|
||||
if (ctl == null) {
|
||||
return Collections.emptyMap();
|
||||
return null;
|
||||
}
|
||||
|
||||
ListMultimap<String, String> permitted = LinkedListMultimap.create();
|
||||
@@ -592,7 +594,7 @@ public class ChangeJson {
|
||||
Collection<LabelInfo> labels) throws OrmException {
|
||||
ChangeControl ctl = control(cd);
|
||||
if (ctl == null) {
|
||||
return ImmutableList.of();
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<Account.Id> fixed = Sets.newHashSetWithExpectedSize(labels.size());
|
||||
@@ -656,7 +658,7 @@ public class ChangeJson {
|
||||
private Map<String, RevisionInfo> revisions(ChangeData cd) throws OrmException {
|
||||
ChangeControl ctl = control(cd);
|
||||
if (ctl == null) {
|
||||
return Collections.emptyMap();
|
||||
return null;
|
||||
}
|
||||
|
||||
Collection<PatchSet> src;
|
||||
|
Reference in New Issue
Block a user