SubmittedTogether: Only show tab if there is more than one change
If the tab contains only the current change, the tab feels pointless and a waste of screen estate. In that case we don't want to display the tab. To do so we choose to modify the REST API for the /submitted_together call, because this keeps the client side code from growing exceptions around the REST API calls. Change-Id: If1943f93f5f5f9bc2dd1e2135e7ab4406e91262e
This commit is contained in:
committed by
Shawn Pearce
parent
0cc78d1134
commit
460f354392
@@ -1073,7 +1073,11 @@ message is contained in the response body.
|
|||||||
--
|
--
|
||||||
|
|
||||||
Returns a list of all changes which are submitted when
|
Returns a list of all changes which are submitted when
|
||||||
link:#submit-change[\{submit\}] is called for this change.
|
link:#submit-change[\{submit\}] is called for this change,
|
||||||
|
including the current change itself.
|
||||||
|
|
||||||
|
An empty list is returned if this change will be submitted
|
||||||
|
by itself (no other changes).
|
||||||
|
|
||||||
.Request
|
.Request
|
||||||
----
|
----
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
|||||||
String id2 = getChangeId(c2_1);
|
String id2 = getChangeId(c2_1);
|
||||||
pushHead(testRepo, "refs/for/master", false);
|
pushHead(testRepo, "refs/for/master", false);
|
||||||
|
|
||||||
assertSubmittedTogether(id1, id1);
|
assertSubmittedTogether(id1);
|
||||||
assertSubmittedTogether(id2, id2, id1);
|
assertSubmittedTogether(id2, id2, id1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void respectsWholeTopicAndAncestors() throws Exception {
|
public void respectsWholeTopicAndAncestors() throws Exception {
|
||||||
RevCommit initialHead = getRemoteHead();
|
RevCommit initialHead = getRemoteHead();
|
||||||
// Create two independant commits and push.
|
// Create two independent commits and push.
|
||||||
RevCommit c1_1 = commitBuilder()
|
RevCommit c1_1 = commitBuilder()
|
||||||
.add("a.txt", "1")
|
.add("a.txt", "1")
|
||||||
.message("subject: 1")
|
.message("subject: 1")
|
||||||
@@ -78,8 +78,45 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
|||||||
assertSubmittedTogether(id1, id2, id1);
|
assertSubmittedTogether(id1, id2, id1);
|
||||||
assertSubmittedTogether(id2, id2, id1);
|
assertSubmittedTogether(id2, id2, id1);
|
||||||
} else {
|
} else {
|
||||||
assertSubmittedTogether(id1, id1);
|
assertSubmittedTogether(id1);
|
||||||
assertSubmittedTogether(id2, id2);
|
assertSubmittedTogether(id2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTopicChaining() throws Exception {
|
||||||
|
RevCommit initialHead = getRemoteHead();
|
||||||
|
// Create two independent commits and push.
|
||||||
|
RevCommit c1_1 = commitBuilder()
|
||||||
|
.add("a.txt", "1")
|
||||||
|
.message("subject: 1")
|
||||||
|
.create();
|
||||||
|
String id1 = getChangeId(c1_1);
|
||||||
|
pushHead(testRepo, "refs/for/master/" + name("connectingTopic"), false);
|
||||||
|
|
||||||
|
testRepo.reset(initialHead);
|
||||||
|
RevCommit c2_1 = commitBuilder()
|
||||||
|
.add("b.txt", "2")
|
||||||
|
.message("subject: 2")
|
||||||
|
.create();
|
||||||
|
String id2 = getChangeId(c2_1);
|
||||||
|
pushHead(testRepo, "refs/for/master/" + name("connectingTopic"), false);
|
||||||
|
|
||||||
|
RevCommit c3_1 = commitBuilder()
|
||||||
|
.add("b.txt", "2")
|
||||||
|
.message("subject: 2")
|
||||||
|
.create();
|
||||||
|
String id3 = getChangeId(c3_1);
|
||||||
|
pushHead(testRepo, "refs/for/master/" + name("unrelated-topic"), false);
|
||||||
|
|
||||||
|
if (isSubmitWholeTopicEnabled()) {
|
||||||
|
assertSubmittedTogether(id1, id2, id1);
|
||||||
|
assertSubmittedTogether(id2, id2, id1);
|
||||||
|
assertSubmittedTogether(id3, id3, id2, id1);
|
||||||
|
} else {
|
||||||
|
assertSubmittedTogether(id1);
|
||||||
|
assertSubmittedTogether(id2);
|
||||||
|
assertSubmittedTogether(id3, id3, id2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +139,8 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
|||||||
String id2 = getChangeId(c2_1);
|
String id2 = getChangeId(c2_1);
|
||||||
pushHead(testRepo, "refs/for/master", false);
|
pushHead(testRepo, "refs/for/master", false);
|
||||||
|
|
||||||
assertSubmittedTogether(id1, id1);
|
assertSubmittedTogether(id1);
|
||||||
assertSubmittedTogether(id2, id2);
|
assertSubmittedTogether(id2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSubmittedTogether(String chId, String... expected)
|
private void assertSubmittedTogether(String chId, String... expected)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -60,12 +61,16 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
|||||||
try {
|
try {
|
||||||
ChangeSet cs = mergeSuperSet.completeChangeSet(dbProvider.get(),
|
ChangeSet cs = mergeSuperSet.completeChangeSet(dbProvider.get(),
|
||||||
ChangeSet.create(resource.getChange()));
|
ChangeSet.create(resource.getChange()));
|
||||||
|
if (cs.ids().size() > 1) {
|
||||||
return json.create(EnumSet.of(
|
return json.create(EnumSet.of(
|
||||||
ListChangesOption.CURRENT_REVISION,
|
ListChangesOption.CURRENT_REVISION,
|
||||||
ListChangesOption.CURRENT_COMMIT,
|
ListChangesOption.CURRENT_COMMIT,
|
||||||
ListChangesOption.DETAILED_LABELS,
|
ListChangesOption.DETAILED_LABELS,
|
||||||
ListChangesOption.LABELS))
|
ListChangesOption.LABELS))
|
||||||
.format(cs.ids());
|
.format(cs.ids());
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
log.error("Error on getting a ChangeSet", e);
|
log.error("Error on getting a ChangeSet", e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
Reference in New Issue
Block a user