RelatedChanges: Don't show "Same Topic" for only one change

When there is only one change in the topic, it doesn't add any value
to show the "Same Topic" tab because it will always only include the
currently viewed change.

Change the query used to get the changes to exclude the current change.

This introduces a slight change in behavior: the "Same Topic" tab now
only shows other changes on the same topic as the current change, but
never includes the current change.

Note that the same issue exists in both the GWT and Polymer UIs, but
this commit only fixes it for GWT.

Bug: Issue 10317
Change-Id: Ibccfb030e91dbe4245fed07b317f8e7dbce5a0f1
This commit is contained in:
David Pursehouse 2019-01-18 10:04:06 +09:00
parent 28f241aeb5
commit 5a6a91c4bb

View File

@ -232,9 +232,13 @@ public class RelatedChanges extends TabPanel {
if (!Gerrit.info().change().isSubmitWholeTopicEnabled()
&& info.topic() != null
&& !"".equals(info.topic())) {
StringBuilder topicQuery = new StringBuilder();
topicQuery.append("status:open");
topicQuery.append(" ").append(op("topic", info.topic()));
StringBuilder topicQuery =
new StringBuilder()
.append("status:open")
.append(" ")
.append(op("-change", info.legacyId().get()))
.append(" ")
.append(op("topic", info.topic()));
ChangeList.query(
topicQuery.toString(),
EnumSet.of(