request

package
v0.0.0-...-be47510 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package request defines the internal representation of a review request.

Index

Constants

View Source
const FormatVersion = 0

FormatVersion defines the latest version of the request format supported by the tool.

View Source
const Ref = "refs/notes/devtools/reviews"

Ref defines the git-notes ref that we expect to contain review requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	// Timestamp and Requester are optimizations that allows us to display reviews
	// 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 reviews grows.
	Timestamp   string   `json:"timestamp,omitempty"`
	ReviewRef   string   `json:"reviewRef,omitempty"`
	TargetRef   string   `json:"targetRef"`
	Requester   string   `json:"requester,omitempty"`
	Reviewers   []string `json:"reviewers,omitempty"`
	Description string   `json:"description,omitempty"`
	// Version represents the version of the metadata format.
	Version int `json:"v,omitempty"`
	// BaseCommit stores the commit ID of the target ref at the time the review was requested.
	// This is optional, and only used for submitted reviews which were anchored at a merge commit.
	// This allows someone viewing that submitted review to find the diff against which the
	// code was reviewed.
	BaseCommit string `json:"baseCommit,omitempty"`
	// Alias stores a post-rebase commit ID for the review. This allows the tool
	// to track the history of a review even if the commit history changes.
	Alias string `json:"alias,omitempty"`

	gpg.Sig
}

Request represents an initial request for a code review.

Every field is optional.

func New

func New(requester string, reviewers []string, reviewRef, targetRef, description string) Request

New returns a new request.

The Timestamp and Requester fields are automatically filled in with the current time and user.

func Parse

func Parse(note repository.Note) (Request, error)

Parse parses a review request from a git note.

func ParseAllValid

func ParseAllValid(notes []repository.Note) []Request

ParseAllValid takes collection of git notes and tries to parse a review request from each one. Any notes that are not valid review requests get ignored, as we expect the git notes to be a heterogenous list, with only some of them being review requests.

func (*Request) Write

func (request *Request) Write() (repository.Note, error)

Write writes a review request as a JSON-formatted git note.

Jump to

Keyboard shortcuts

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