Documentation
¶
Overview ¶
Package comment defines the internal representation of a review comment.
Index ¶
Constants ¶
const FormatVersion = 0
FormatVersion defines the latest version of the comment format supported by the tool.
const Ref = "refs/notes/devtools/discuss"
Ref defines the git-notes ref that we expect to contain review comments.
Variables ¶
var ErrInvalidRange = errors.New("invalid file location range. The required form is StartLine[+StartColumn][:EndLine[+EndColumn]]. The first line in a file is considered to be line 1")
ErrInvalidRange inidcates an error during parsing of a user-defined file range
Functions ¶
func ParseAllValid ¶
func ParseAllValid(notes []repository.Note) map[string]Comment
ParseAllValid takes collection of git notes and tries to parse a review comment from each one. Any notes that are not valid review comments get ignored, as we expect the git notes to be a heterogenous list, with only some of them being review comments.
Types ¶
type Comment ¶
type Comment struct {
// Timestamp and Author are optimizations that allows us to display comment threads
// without having to run git-blame over the notes object. This is done because
// git-blame will become more and more expensive as the number of code reviews grows.
Timestamp string `json:"timestamp,omitempty"`
Author string `json:"author,omitempty"`
// If original is provided, then the comment is an updated version of another comment.
Original string `json:"original,omitempty"`
// If parent is provided, then the comment is a response to another comment.
Parent string `json:"parent,omitempty"`
// If location is provided, then the comment is specific to that given location.
Location *Location `json:"location,omitempty"`
Description string `json:"description,omitempty"`
// The resolved bit indicates that no further action is needed.
//
// When the parent of the comment is another comment, this means that comment
// has been addressed. Otherwise, the parent is the commit, and this means that the
// change has been accepted. If the resolved bit is unset, then the comment is only an FYI.
Resolved *bool `json:"resolved,omitempty"`
// Version represents the version of the metadata format.
Version int `json:"v,omitempty"`
gpg.Sig
}
Comment represents a review comment, and can occur in any of the following contexts: 1. As a comment on an entire commit. 2. As a comment about a specific file in a commit. 3. As a comment about a specific line in a commit. 4. As a response to another comment.
func New ¶
New returns a new comment with the given description message.
The Timestamp and Author fields are automatically filled in with the current time and user.
func Parse ¶
func Parse(note repository.Note) (Comment, error)
Parse parses a review comment from a git note.
type Location ¶
type Location struct {
Commit string `json:"commit,omitempty"`
// If the path is omitted, then the comment applies to the entire commit.
Path string `json:"path,omitempty"`
// If the range is omitted, then the location represents an entire file.
Range *Range `json:"range,omitempty"`
}
Location represents the location of a comment within a commit.
type Range ¶
type Range struct {
StartLine uint32 `json:"startLine"`
StartColumn uint32 `json:"startColumn,omitempty"`
EndLine uint32 `json:"endLine,omitempty"`
EndColumn uint32 `json:"endColumn,omitempty"`
}
Range represents the range of text that is under discussion.