gerrit: add more fields to ChangeInfo

For details, see
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info

Note that the field Mergable has been renamed Mergeable,
and its JSON tag has been corrected from mergable to mergeable.
If this breaks any existing code using the gerrit package,
that code should be examined, since it has never seen a
mergeable change as actually mergeable in the past.

Change-Id: I769abeed173c7afd7da7b1527f810d0a2db18236
Reviewed-on: https://go-review.googlesource.com/c/149239
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/gerrit/gerrit.go b/gerrit/gerrit.go
index d2f2548..a88d331 100644
--- a/gerrit/gerrit.go
+++ b/gerrit/gerrit.go
@@ -168,6 +168,7 @@
 	// refs/heads/ prefix is omitted.
 	ID           string `json:"id"`
 	ChangeNumber int    `json:"_number"`
+	ChangeID     string `json:"change_id"`
 
 	Project string `json:"project"`
 
@@ -175,17 +176,37 @@
 	// The refs/heads/ prefix is omitted.
 	Branch string `json:"branch"`
 
-	ChangeID string `json:"change_id"`
+	Topic    string       `json:"topic"`
+	Assignee *AccountInfo `json:"assignee"`
+	Hashtags []string     `json:"hashtags"`
 
+	// Subject is the subject of the change
+	// (the header line of the commit message).
 	Subject string `json:"subject"`
 
 	// Status is the status of the change (NEW, SUBMITTED, MERGED,
 	// ABANDONED, DRAFT).
 	Status string `json:"status"`
 
-	Created  TimeStamp `json:"created"`
-	Updated  TimeStamp `json:"updated"`
-	Mergable bool      `json:"mergable"`
+	Created    TimeStamp    `json:"created"`
+	Updated    TimeStamp    `json:"updated"`
+	Submitted  TimeStamp    `json:"submitted"`
+	Submitter  *AccountInfo `json:"submitter"`
+	SubmitType string       `json:"submit_type"`
+
+	// Mergeable indicates whether the change can be merged.
+	// It is not set for already-merged changes,
+	// nor if the change is untested, nor if the
+	// SKIP_MERGEABLE option has been set.
+	Mergeable bool `json:"mergeable"`
+
+	// Submittable indicates whether the change can be submitted.
+	// It is only set if requested, using the "SUBMITTABLE" option.
+	Submittable bool `json:"submittable"`
+
+	// Insertions and Deletions count inserted and deleted lines.
+	Insertions int `json:"insertions"`
+	Deletions  int `json:"deletions"`
 
 	// CurrentRevision is the commit ID of the current patch set
 	// of this change.  This is only set if the current revision
@@ -208,15 +229,46 @@
 	// Messages are included if field "MESSAGES" is requested.
 	Messages []ChangeMessageInfo `json:"messages"`
 
+	// Labels maps label names to LabelInfo entries.
 	Labels map[string]LabelInfo `json:"labels"`
 
-	// TODO: more as needed
+	// ReviewerUpdates are included if field "REVIEWER_UPDATES" is requested.
+	ReviewerUpdates []ReviewerUpdateInfo `json:"reviewer_updates"`
+
+	// Reviewers maps reviewer state ("REVIEWER", "CC", "REMOVED")
+	// to a list of accounts.
+	// REVIEWER lists users with at least one non-zero vote on the change.
+	// CC lists users added to the change who has not voted.
+	// REMOVED lists users who were previously reviewers on the change
+	// but who have been removed.
+	// Reviewers is only included if "DETAILED_LABELS" is requested.
+	Reviewers map[string][]*AccountInfo `json:"reviewers"`
+
+	// WorkInProgress indicates that the change is marked as a work in progress.
+	// (This means it is not yet ready for review, but it is still publicly visible.)
+	WorkInProgress bool `json:"work_in_progress"`
+
+	// HasReviewStarted indicates whether the change has ever been marked
+	// ready for review in the past (not as a work in progress).
+	HasReviewStarted bool `json:"has_review_started"`
+
+	// RevertOf lists the numeric Change-Id of the change that this change reverts.
+	RevertOf int `json:"revert_of"`
 
 	// MoreChanges is set on the last change from QueryChanges if
 	// the result set is truncated by an 'n' parameter.
 	MoreChanges bool `json:"_more_changes"`
 }
 
+// ReviewerUpdateInfo is a Gerrit data structure.
+// See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#review-update-info
+type ReviewerUpdateInfo struct {
+	Updated   TimeStamp    `json:"updated"`
+	UpdatedBy *AccountInfo `json:"updated_by"`
+	Reviewer  *AccountInfo `json:"reviewer"`
+	State     string       // "REVIEWER", "CC", or "REMOVED"
+}
+
 // AccountInfo is a Gerrit data structure. It's used both for getting the details
 // for a single account, as well as for querying multiple accounts.
 type AccountInfo struct {