Merge "Avoid empty web_links element inside of RevisionInfo"
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.gerrit.extensions.webui.ProjectWebLink;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
@@ -45,8 +46,8 @@ public class WebLinks {
|
||||
this.branchLinks = branchLinks;
|
||||
}
|
||||
|
||||
public Iterable<WebLinkInfo> getPatchSetLinks(String project, String commit) {
|
||||
List<WebLinkInfo> links = Lists.newArrayList();
|
||||
public List<WebLinkInfo> getPatchSetLinks(String project, String commit) {
|
||||
List<WebLinkInfo> links = new ArrayList<>(4);
|
||||
for (PatchSetWebLink webLink : patchSetLinks) {
|
||||
links.add(new WebLinkInfo(webLink.getLinkName(),
|
||||
webLink.getImageUrl(),
|
||||
|
||||
@@ -843,11 +843,9 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
if (has(WEB_LINKS)) {
|
||||
out.webLinks = Lists.newArrayList();
|
||||
for (WebLinkInfo link : webLinks.getPatchSetLinks(
|
||||
project, in.getRevision().get())) {
|
||||
out.webLinks.add(link);
|
||||
}
|
||||
List<WebLinkInfo> links =
|
||||
webLinks.getPatchSetLinks(project, in.getRevision().get());
|
||||
out.webLinks = !links.isEmpty() ? links : null;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user