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.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -45,8 +46,8 @@ public class WebLinks {
|
|||||||
this.branchLinks = branchLinks;
|
this.branchLinks = branchLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<WebLinkInfo> getPatchSetLinks(String project, String commit) {
|
public List<WebLinkInfo> getPatchSetLinks(String project, String commit) {
|
||||||
List<WebLinkInfo> links = Lists.newArrayList();
|
List<WebLinkInfo> links = new ArrayList<>(4);
|
||||||
for (PatchSetWebLink webLink : patchSetLinks) {
|
for (PatchSetWebLink webLink : patchSetLinks) {
|
||||||
links.add(new WebLinkInfo(webLink.getLinkName(),
|
links.add(new WebLinkInfo(webLink.getLinkName(),
|
||||||
webLink.getImageUrl(),
|
webLink.getImageUrl(),
|
||||||
|
|||||||
@@ -843,11 +843,9 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has(WEB_LINKS)) {
|
if (has(WEB_LINKS)) {
|
||||||
out.webLinks = Lists.newArrayList();
|
List<WebLinkInfo> links =
|
||||||
for (WebLinkInfo link : webLinks.getPatchSetLinks(
|
webLinks.getPatchSetLinks(project, in.getRevision().get());
|
||||||
project, in.getRevision().get())) {
|
out.webLinks = !links.isEmpty() ? links : null;
|
||||||
out.webLinks.add(link);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user