Add a /changes option to include detailed label info

The intent of this option is to be able to render the ApprovalTable
using the new REST API. As such, we need to display detailed approval
info for all relevant accounts, not just the output of the submit rule
evaluator. The submit rule evaluator only outputs at most one account
for approved/recommended/disliked/rejected, and omits the numeric
value.

Detailed label information is included in the "labels" field, which is
all per-change information. The permitted ranges for the current user,
which is of course per-user, is included in the top-level
"permitted_labels" field.

Example JSON output for a change:

  {
    "kind": "gerritcodereview#change",
    "id": "repo1~master~I190d6f46480fbc160561bea7e46d1c0905d75a80",
    "project": "repo1",
    "branch": "master",
    "change_id": "I190d6f46480fbc160561bea7e46d1c0905d75a80",
    "subject": "Add bar/baz",
    "status": "NEW",
    "created": "2013-01-29 21:37:03.870000000",
    "updated": "2013-02-06 00:17:26.751000000",
    "reviewed": true,
    "_sortkey": "0022ea3100000002",
    "_number": 2,
    "owner": {
      "_account_id": 1000000,
      "name": "Dave Borowitz",
      "email": "dborowitz@google.com"
    },
    "labels": {
      "Verified": {
        "all": [
          {
            "value": 1,
            "_account_id": 1000000,
            "name": "Dave Borowitz",
            "email": "dborowitz@google.com"
          }
        ],
        "values": {
          "-1": "Fails",
          " 0": "No score",
          "+1": "Verified"
        }
      },
      "Code-Review": {
        "all": [
          {
            "value": 1,
            "_account_id": 1000000,
            "name": "Dave Borowitz",
            "email": "dborowitz@google.com"
          },
          {
            "value": -1,
            "_account_id": 1000001,
            "name": "David Borowitz",
            "email": "ddborowitz@gmail.com"
          }
        ],
        "values": {
          "-2": "Do not submit",
          "-1": "I would prefer that you didn\u0027t submit this",
          " 0": "No score",
          "+1": "Looks good to me, but someone else must approve",
          "+2": "Looks good to me, approved"
        }
      }
    },
    "permitted_labels": {
      "Code-Review": [
        "-1",
        " 0",
        "+1"
      ]
    }
  }

Change-Id: I97e97fa0cb27cc3dbdc8496d5115dc353dafc9ae
This commit is contained in:
Dave Borowitz
2013-01-30 16:18:59 -08:00
parent a5d6eadbf2
commit 4c7231a910
5 changed files with 227 additions and 42 deletions

View File

@@ -19,6 +19,7 @@ import java.util.EnumSet;
/** Output options available when using {@code /changes/} RPCs. */
public enum ListChangesOption {
LABELS(0),
DETAILED_LABELS(8),
/** Return information on the current patch set of the change. */
CURRENT_REVISION(1),