Check for a revision before request
When using the inline edit feature to add a depens-on element to the
commit message the revision may not be available for the REST
request. Check to make sure it's available before showing getting
the data.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java b/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java
index c12ceb8..5a49614 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java
@@ -42,21 +42,23 @@
final RevisionInfo rev =
panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- new RestApi("changes").id(change.id()).view("revisions").id(rev.id())
- .view(Plugin.get().getPluginName(), "dependency")
- .get(new AsyncCallback<DependencyInfo>() {
- @Override
- public void onSuccess(DependencyInfo result) {
- if (result != null) {
- display(result);
+ if (!rev.isEdit()) {
+ new RestApi("changes").id(change.id()).view("revisions").id(rev.id())
+ .view(Plugin.get().getPluginName(), "dependency")
+ .get(new AsyncCallback<DependencyInfo>() {
+ @Override
+ public void onSuccess(DependencyInfo result) {
+ if (result != null) {
+ display(result);
+ }
}
- }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
+ }
}
private void display(DependencyInfo result) {