review

package
v0.0.0-...-413351d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2020 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package review contains the data structures used to represent code reviews.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentThread

type CommentThread struct {
	Hash     string             `json:"hash,omitempty"`
	Comment  comment.Comment    `json:"comment"`
	Original *comment.Comment   `json:"original,omitempty"`
	Edits    []*comment.Comment `json:"edits,omitempty"`
	Children []CommentThread    `json:"children,omitempty"`
	Resolved *bool              `json:"resolved,omitempty"`
	Edited   bool               `json:"edited,omitempty"`
}

CommentThread represents the tree-based hierarchy of comments.

The Resolved field represents the aggregate status of the entire thread. If it is set to false, then it indicates that there is an unaddressed comment in the thread. If it is unset, then that means that the root comment is an FYI only, and that there are no unaddressed comments. If it is set to true, then that means that there are no unaddressed comments, and that the root comment has its resolved bit set to true.

func (*CommentThread) Verify

func (thread *CommentThread) Verify() error

Verify verifies the signature on a comment.

type Review

type Review struct {
	*Summary
	Reports  []ci.Report       `json:"reports,omitempty"`
	Analyses []analyses.Report `json:"analyses,omitempty"`
}

Review represents the entire state of a code review.

This extends Summary to also include a list of reports for both the continuous integration status, and the static analysis runs. Those reports correspond to either the current commit in the review ref (for pending reviews), or to the last commented-upon commit (for submitted reviews).

func Get

func Get(repo repository.Repo, revision string) (*Review, error)

Get returns the specified code review.

If no review request exists, the returned review is nil.

func GetCurrent

func GetCurrent(repo repository.Repo) (*Review, error)

GetCurrent returns the current, open code review.

If there are multiple matching reviews, then an error is returned.

func (*Review) AddComment

func (r *Review) AddComment(c comment.Comment) error

AddComment adds the given comment to the review.

func (*Review) GetAnalysesMessage

func (r *Review) GetAnalysesMessage() string

GetAnalysesMessage returns a string summarizing the results of the most recent static analyses.

func (*Review) GetAnalysesNotes

func (r *Review) GetAnalysesNotes() ([]analyses.Note, error)

GetAnalysesNotes returns all of the notes from the most recent static analysis run recorded in the git notes.

func (*Review) GetBaseCommit

func (r *Review) GetBaseCommit() (string, error)

GetBaseCommit returns the commit against which a review should be compared.

func (*Review) GetBuildStatusMessage

func (r *Review) GetBuildStatusMessage() string

GetBuildStatusMessage returns a string of the current build-and-test status of the review, or "unknown" if the build-and-test status cannot be determined.

func (*Review) GetDiff

func (r *Review) GetDiff(diffArgs ...string) (string, error)

GetDiff returns the diff for a review.

func (*Review) GetHeadCommit

func (r *Review) GetHeadCommit() (string, error)

GetHeadCommit returns the latest commit in a review.

func (*Review) GetJSON

func (r *Review) GetJSON() (string, error)

GetJSON returns the pretty printed JSON for a review.

func (*Review) ListCommits

func (r *Review) ListCommits() ([]string, error)

ListCommits lists the commits included in a review.

func (*Review) Rebase

func (r *Review) Rebase(archivePrevious bool) error

Rebase performs an interactive rebase of the review onto its target ref.

If the 'archivePrevious' argument is true, then the previous head of the review will be added to the 'refs/devtools/archives/reviews' ref prior to being rewritten. That ensures the review history is kept from being garbage collected.

func (*Review) RebaseAndSign

func (r *Review) RebaseAndSign(archivePrevious bool) error

RebaseAndSign performs an interactive rebase of the review onto its target ref. It signs the result of the rebase as well as (re)signs the review request itself.

If the 'archivePrevious' argument is true, then the previous head of the review will be added to the 'refs/devtools/archives/reviews' ref prior to being rewritten. That ensures the review history is kept from being garbage collected.

type Summary

type Summary struct {
	Repo        repository.Repo   `json:"-"`
	Revision    string            `json:"revision"`
	Request     request.Request   `json:"request"`
	AllRequests []request.Request `json:"-"`
	Comments    []CommentThread   `json:"comments,omitempty"`
	Resolved    *bool             `json:"resolved,omitempty"`
	Submitted   bool              `json:"submitted"`
}

Summary represents the high-level state of a code review.

This high-level state corresponds to the data that can be quickly read directly from the repo, so other methods that need to operate on a lot of reviews (such as listing the open reviews) should prefer operating on the summary rather than the details.

Review summaries have two status fields which are orthogonal: 1. Resolved indicates if a reviewer has accepted or rejected the change. 2. Submitted indicates if the change has been incorporated into the target.

func GetSummary

func GetSummary(repo repository.Repo, revision string) (*Summary, error)

GetSummary returns the summary of the specified code review.

If no review request exists, the returned review summary is nil.

func GetSummaryViaRefs

func GetSummaryViaRefs(repo repository.Repo, requestRef, commentRef,
	revision string) (*Summary, error)

GetSummary returns the summary of the code review specified by its revision and the references which contain that reviews summary and comments.

If no review request exists, the returned review summary is nil.

func ListAll

func ListAll(repo repository.Repo) []Summary

ListAll returns all reviews stored in the git-notes.

func ListOpen

func ListOpen(repo repository.Repo) []Summary

ListOpen returns all reviews that are not yet incorporated into their target refs.

func (*Summary) Details

func (r *Summary) Details() (*Review, error)

Details returns the detailed review for the given summary.

func (*Summary) GetJSON

func (r *Summary) GetJSON() (string, error)

GetJSON returns the pretty printed JSON for a review summary.

func (*Summary) IsAbandoned

func (r *Summary) IsAbandoned() bool

IsAbandoned returns whether or not the given review has been abandoned.

func (*Summary) IsOpen

func (r *Summary) IsOpen() bool

IsOpen returns whether or not the given review is still open (neither submitted nor abandoned).

func (*Summary) Verify

func (r *Summary) Verify() error

Verify returns whether or not a summary's comments are a) signed, and b) / that those signatures are verifiable.

Directories

Path Synopsis
Package analyses defines the internal representation of static analysis reports.
Package analyses defines the internal representation of static analysis reports.
Package ci defines the internal representation of a continuous integration reports.
Package ci defines the internal representation of a continuous integration reports.
Package comment defines the internal representation of a review comment.
Package comment defines the internal representation of a review comment.
Package gpg provides an interface and an abstraction with which to sign and verify review requests and comments.
Package gpg provides an interface and an abstraction with which to sign and verify review requests and comments.
Package request defines the internal representation of a review request.
Package request defines the internal representation of a review request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL