Add ready property to ReviewResult

This is particularly needed for transitioning PolyGerrit to use this new
API. We can use this property to determine immediately upon receiving a
response to posting a review whether we need to fall back to a second
API call to start review.

Bug: Issue 6760
Change-Id: Ib0ef5f5a0d454de4cd4b9496ab1cf81dba729a99
This commit is contained in:
Logan Hanks
2017-07-18 09:45:46 -07:00
parent e7cd29bc20
commit e81ad8e57e
4 changed files with 16 additions and 2 deletions

View File

@@ -6737,6 +6737,9 @@ Map of account or group identifier to
link:rest-api-changes.html#add-reviewer-result[AddReviewerResult]
representing the outcome of adding as a reviewer.
Absent if no reviewer additions were requested.
|`ready` |optional|
If true, the change was moved from WIP to ready for review as a result of this
action. Not set if false.
|============================
[[reviewer-info]]

View File

@@ -510,7 +510,8 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(r.getChange().change().isWorkInProgress()).isTrue();
ReviewInput in = ReviewInput.noScore().setWorkInProgress(false);
gApi.changes().id(r.getChangeId()).revision("current").review(in);
ReviewResult result = gApi.changes().id(r.getChangeId()).revision("current").review(in);
assertThat(result.ready).isTrue();
ChangeInfo info = gApi.changes().id(r.getChangeId()).get();
assertThat(info.workInProgress).isNull();
@@ -523,7 +524,8 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(r.getChange().change().isWorkInProgress()).isFalse();
ReviewInput in = ReviewInput.noScore().setWorkInProgress(true);
gApi.changes().id(r.getChangeId()).revision("current").review(in);
ReviewResult result = gApi.changes().id(r.getChangeId()).revision("current").review(in);
assertThat(result.ready).isNull();
ChangeInfo info = gApi.changes().id(r.getChangeId()).get();
assertThat(info.workInProgress).isTrue();

View File

@@ -31,6 +31,11 @@ public class ReviewResult {
*/
@Nullable public Map<String, AddReviewerResult> reviewers;
/**
* Boolean indicating whether the change was moved out of WIP by this review. Either true or null.
*/
@Nullable public Boolean ready;
/** Error message for non-200 responses. */
@Nullable public String error;
}

View File

@@ -330,6 +330,10 @@ public class PostReview
output.error = ERROR_ONLY_OWNER_CAN_MODIFY_WORK_IN_PROGRESS;
return Response.withStatusCode(SC_BAD_REQUEST, output);
}
if (input.ready) {
output.ready = true;
}
// Suppress notifications in WorkInProgressOp, we'll take care of
// them in this endpoint.
WorkInProgressOp.Input wipIn = new WorkInProgressOp.Input();