diff options
| author | Russ Cox <rsc@golang.org> | 2021-02-17 10:23:46 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-02-18 16:25:55 -0500 |
| commit | de39345c7586e9110d8699d299bdc8100f35a5cb (patch) | |
| tree | b797a25ac295ed44ef263192c8c8b31d98a8a198 | |
| parent | 19899311a872616f0eb00d6eadccc1109d9047d3 (diff) | |
| download | go-x-review-1.0.1.tar.xz | |
hackv1.0.1
Change-Id: I1c289dde45230a3362f54037ea18023278b05ffd
| -rw-r--r-- | git-codereview/api.go | 83 | ||||
| -rw-r--r-- | git-codereview/branch.go | 5 | ||||
| -rw-r--r-- | git-codereview/pending.go | 3 |
3 files changed, 71 insertions, 20 deletions
diff --git a/git-codereview/api.go b/git-codereview/api.go index afd421f..2adbcce 100644 --- a/git-codereview/api.go +++ b/git-codereview/api.go @@ -372,24 +372,26 @@ func readGerritChangesBatch(query string, n int, ch chan gerritChangeResult) { ch <- gerritChangeResult{c, err} } -// GerritChange is the JSON struct returned by a Gerrit CL query. +// GerritChange is the JSON struct for a Gerrit ChangeInfo, returned by a Gerrit CL query. type GerritChange struct { - ID string - Project string - Branch string - ChangeId string `json:"change_id"` - Subject string - Status string - Created string - Updated string - Insertions int - Deletions int - Number int `json:"_number"` - Owner *GerritAccount - Labels map[string]*GerritLabel - CurrentRevision string `json:"current_revision"` - Revisions map[string]*GerritRevision - Messages []*GerritMessage + ID string + Project string + Branch string + ChangeId string `json:"change_id"` + Subject string + Status string + Created string + Updated string + Insertions int + Deletions int + Number int `json:"_number"` + Owner *GerritAccount + Labels map[string]*GerritLabel + CurrentRevision string `json:"current_revision"` + Revisions map[string]*GerritRevision + Messages []*GerritMessage + TotalCommentCount int `json:"total_comment_count"` + UnresolvedCommentCount int `json:"unresolved_comment_count"` } // LabelNames returns the label names for the change, in lexicographic order. @@ -441,8 +443,53 @@ type GerritRevision struct { Fetch map[string]*GerritFetch } -// GerritFetch is the JSON struct for a Gerrit FetchInfo +// GerritFetch is the JSON struct for a Gerrit FetchInfo. type GerritFetch struct { URL string Ref string } + +// GerritComment is the JSON struct for a Gerrit CommentInfo. +type GerritComment struct { + PatchSet string `json:"patch_set"` + ID string + Path string + Side string + Parent string + Line string + Range *GerritCommentRange + InReplyTo string + Message string + Updated string + Author *GerritAccount + Tag string + Unresolved bool + ChangeMessageID string `json:"change_message_id"` + CommitID string `json:"commit_id"` // SHA1 hex +} + +// GerritCommentRange is the JSON struct for a Gerrit CommentRange. +type GerritCommentRange struct { + StartLine int `json:"start_line"` // 1-based + StartCharacter int `json:"start_character"` // 0-based + EndLine int `json:"end_line"` // 1-based + EndCharacter int `json:"end_character"` // 0-based +} + +// GerritContextLine is the JSON struct for a Gerrit ContextLine. +type GerritContextLine struct { + LineNumber int `json:"line_number"` // 1-based + ContextLine string `json:"context_line"` +} + +// GerritCommentInput is the JSON struct for a Gerrit CommentInput. +type GerritCommentInput struct { + ID string `json:"id,omitempty"` // ID of a draft comment to update + Path string `json:"path,omitempty"` // file to attach comment to + Side string `json:"side,omitempty"` // REVISION (default) or PARENT + Line int `json:"line,omitempty"` // 0 to use range (or else file comment) + Range *GerritCommentRange `json:"range,omitempty"` + InReplyTo string `json:"in_reply_to,omitempty"` // ID of comment being replied to + Message string `json:"message,omitempty"` + Unresolved *bool `json:"unresolved,omitempty"` // defaults to parent setting or else false +} diff --git a/git-codereview/branch.go b/git-codereview/branch.go index d25c4c9..37da5fa 100644 --- a/git-codereview/branch.go +++ b/git-codereview/branch.go @@ -273,7 +273,6 @@ Log: c := &Commit{ Hash: fields[i], ShortHash: fields[i+1], - Parent: parents[0], Parents: parents, Tree: fields[i+3], Message: fields[i+4], @@ -282,7 +281,9 @@ Log: AuthorEmail: fields[i+7], AuthorDate: fields[i+8], } - + if len(c.Parents) > 0 { + c.Parent = c.Parents[0] + } if len(c.Parents) > 1 { // Found merge point. // Merges break the invariant that the last shared commit (the branchpoint) diff --git a/git-codereview/pending.go b/git-codereview/pending.go index 3ed50ec..671102d 100644 --- a/git-codereview/pending.go +++ b/git-codereview/pending.go @@ -332,6 +332,9 @@ func formatCommit(w io.Writer, c *Commit, short bool) { } tags = append(tags, "merge="+strings.Join(h, ",")) } + if g.UnresolvedCommentCount > 0 { + tags = append(tags, fmt.Sprintf("%d unresolved", g.UnresolvedCommentCount)) + } if len(tags) > 0 { fmt.Fprintf(w, " (%s)", strings.Join(tags, ", ")) } |
