Fix ssh query output for '--depends-on--all' search attribute
Currently, the switch fails to add the depends-on information because of
error [1], when '--format JSON' option is not used. Make the fields
public to fix the issue.
[1] java.lang.IllegalAccessException: class com.google.gerrit.server.query.change.OutputStreamQuery cannot access a member of class com.googlesource.gerrit.plugins.depends.on.DependsOnAttributeFactory$DependsOnAttribute with modifiers "protected"
Change-Id: Ic07ac5c72a688d01c521fa857ffe95aea92e7edd
diff --git a/src/main/java/com/googlesource/gerrit/plugins/depends/on/DependsOnAttributeFactory.java b/src/main/java/com/googlesource/gerrit/plugins/depends/on/DependsOnAttributeFactory.java
index 3badb76..5688e5a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/depends/on/DependsOnAttributeFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/depends/on/DependsOnAttributeFactory.java
@@ -78,8 +78,8 @@
}
protected static class DependsOnAttribute {
- @Nullable protected Integer changeNumber;
- @Nullable protected String unresolved;
+ @Nullable public Integer changeNumber;
+ @Nullable public String unresolved;
public DependsOnAttribute(DependsOn dependsOn) {
if (dependsOn.isResolved()) {
diff --git a/test/test_dependson.sh b/test/test_dependson.sh
index 6dc4a0e..f86f7b1 100755
--- a/test/test_dependson.sh
+++ b/test/test_dependson.sh
@@ -221,6 +221,15 @@
# ------------------------- Depends-on query Test ---------------------------
change=$(create_change "$SRC_REF_BRANCH" "$FILE_A") || exit
+gssh gerrit review --message \'"Depends-on: 10 abc"\' "$change",1
+out=$(gssh gerrit query "change:$change" --depends-on--all)
+result "depends-on query without JSON SSH"
+result_out "depends-on query output 1 without JSON SSH" "changeNumber: 10" \
+ "$(echo "$out" | tail -8 | head -1 | xargs)"
+result_out "depends-on query output 2 without JSON SSH" "unresolved: abc" \
+ "$(echo "$out" | tail -6 | head -1 | xargs)"
+
+change=$(create_change "$SRC_REF_BRANCH" "$FILE_A") || exit
gssh gerrit review --message \
\'"Depends-on: 10 30 Ieace383c14de79bf202c85063d5a46a0580724dd 20"\' "$change",1
out=$(query_ssh "change:$change" --depends-on--all | jq --raw-output '.plugins[0].dependsOns')