Merge "Use the same ListChangeOptions in test that PolyGerrit uses, fix action"
diff --git a/java/com/google/gerrit/server/restapi/change/Rebase.java b/java/com/google/gerrit/server/restapi/change/Rebase.java
index 0c3f6c2..afb674b 100644
--- a/java/com/google/gerrit/server/restapi/change/Rebase.java
+++ b/java/com/google/gerrit/server/restapi/change/Rebase.java
@@ -236,7 +236,11 @@
if (hasOneParent(rw, rsrc.getPatchSet())) {
enabled = rebaseUtil.canRebase(rsrc.getPatchSet(), change.getDest(), repo, rw);
}
- } catch (IOException e) {
+ } catch (Exception e) {
+ // Be generous here with the exceptions that we log and swallow. RebaseUtil#canRebase uses the
+ // change index and this UI action is on the critical path of rendering a change details page.
+ // If the index is broken, we log and disable the UI action, but still show the page to the
+ // user.
logger.atSevere().withCause(e).log(
"Failed to check if patch set can be rebased: %s", rsrc.getPatchSet());
return description;
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
index c38f686..4d1f62f 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
@@ -4204,11 +4204,25 @@
@Test
public void changeDetailsDoesNotRequireIndex() throws Exception {
- PushOneCommit.Result change = createChange();
- int number = gApi.changes().id(change.getChangeId()).get()._number;
+ // This set of options must be kept in sync with gr-rest-api-interface.js
+ Set<ListChangesOption> options =
+ ImmutableSet.of(
+ ListChangesOption.ALL_COMMITS,
+ ListChangesOption.ALL_REVISIONS,
+ ListChangesOption.CHANGE_ACTIONS,
+ ListChangesOption.CURRENT_ACTIONS,
+ ListChangesOption.DETAILED_LABELS,
+ ListChangesOption.DOWNLOAD_COMMANDS,
+ ListChangesOption.MESSAGES,
+ ListChangesOption.SUBMITTABLE,
+ ListChangesOption.WEB_LINKS,
+ ListChangesOption.SKIP_MERGEABLE);
- try (AutoCloseable ctx = disableChangeIndex()) {
- assertThat(gApi.changes().id(project.get(), number).get(ImmutableSet.of()).changeId)
+ PushOneCommit.Result change = createChange();
+ int number = gApi.changes().id(change.getChangeId()).get(options)._number;
+
+ try (AutoCloseable ignored = disableChangeIndex()) {
+ assertThat(gApi.changes().id(project.get(), number).get().changeId)
.isEqualTo(change.getChangeId());
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
index 2c4404d..ec14af5 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
@@ -1321,6 +1321,8 @@
* @param {function()=} opt_cancelCondition
*/
getChangeDetail(changeNum, opt_errFn, opt_cancelCondition) {
+ // This list MUST be kept in sync with
+ // ChangeIT#changeDetailsDoesNotRequireIndex
const options = [
this.ListChangesOption.ALL_COMMITS,
this.ListChangesOption.ALL_REVISIONS,