review

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Applicability

func Applicability(comment ReviewComment, repository *RepositoryDiff) string

func Error

func Error(status int, format string, values ...any) error

func FormatComments

func FormatComments(comments []ReviewComment, includeResolved bool, repositories []RepositoryDiff) string

func Message

func Message(value string) *string

func PatchContext

func PatchContext(patch, side string, start, end int) (string, bool)

func RemoteRepositoryName

func RemoteRepositoryName(remote, fallback string) string

Types

type ChangedFile

type ChangedFile struct {
	ID             string  `json:"id"`
	Path           string  `json:"path"`
	OldPath        *string `json:"oldPath"`
	Status         string  `json:"status"`
	IndexStatus    string  `json:"indexStatus"`
	WorktreeStatus string  `json:"worktreeStatus"`
	Additions      int     `json:"additions"`
	Deletions      int     `json:"deletions"`
	Binary         bool    `json:"binary"`
	Fingerprint    string  `json:"fingerprint"`
	Recreated      bool    `json:"recreated,omitempty"`
}

type DiffMode

type DiffMode string
const (
	DiffAll      DiffMode = "all"
	DiffStaged   DiffMode = "staged"
	DiffUnstaged DiffMode = "unstaged"
)

func ParseDiffMode

func ParseDiffMode(value string) (DiffMode, error)

type FileContents

type FileContents struct {
	Before string `json:"before"`
	After  string `json:"after"`
}

type FilePatch

type FilePatch struct {
	Patch    string        `json:"patch"`
	Message  *string       `json:"message"`
	Contents *FileContents `json:"contents,omitempty"`
}

type RepositoryDiff

type RepositoryDiff struct {
	ID           string        `json:"id"`
	VersionID    string        `json:"versionId"`
	LocationID   *string       `json:"locationId"`
	RepositoryID *string       `json:"repositoryId"`
	Source       string        `json:"source"`
	Root         string        `json:"root"`
	Name         string        `json:"name"`
	Branch       string        `json:"branch"`
	Head         *string       `json:"head"`
	Mode         DiffMode      `json:"mode"`
	Files        []ChangedFile `json:"files"`
	Revision     string        `json:"revision"`
}

type RequestError

type RequestError struct {
	Status int
	Detail string
}

func (*RequestError) Error

func (err *RequestError) Error() string

type ReviewComment

type ReviewComment struct {
	ID          string        `json:"id"`
	DiffID      string        `json:"diffId"`
	VersionID   string        `json:"versionId"`
	Path        string        `json:"path"`
	Scope       DiffMode      `json:"scope"`
	Fingerprint string        `json:"fingerprint"`
	Target      string        `json:"target,omitempty"`
	Side        string        `json:"side"`
	Start       int           `json:"start"`
	End         int           `json:"end"`
	Code        string        `json:"code"`
	Body        string        `json:"body"`
	Status      string        `json:"status"`
	CreatedAt   float64       `json:"createdAt"`
	Origin      *ReviewOrigin `json:"origin,omitempty"`
}

func (ReviewComment) Valid

func (comment ReviewComment) Valid() bool

type ReviewFileOrigin

type ReviewFileOrigin struct {
	Status  string  `json:"status"`
	OldPath *string `json:"oldPath"`
}

type ReviewMark

type ReviewMark struct {
	DiffID      string   `json:"diffId"`
	VersionID   string   `json:"versionId"`
	FileID      string   `json:"fileId"`
	FileVersion string   `json:"fileVersion"`
	Scope       DiffMode `json:"scope"`
}

type ReviewOrigin

type ReviewOrigin struct {
	DiffID     string           `json:"diffId"`
	VersionID  string           `json:"versionId"`
	Source     string           `json:"source"`
	Repository string           `json:"repository"`
	Branch     string           `json:"branch"`
	Head       *string          `json:"head"`
	Revision   string           `json:"revision"`
	File       ReviewFileOrigin `json:"file"`
}

type Source

type Source interface {
	Root() string
	Kind() string
	Support() Support
	Snapshot(context.Context, DiffMode) (RepositoryDiff, error)
	Patch(context.Context, DiffMode, ChangedFile, *string) (FilePatch, error)
	Contents(context.Context, DiffMode, ChangedFile, *string) (FileContents, error)
}

type Support

type Support struct {
	Scopes          []DiffMode
	Refresh         bool
	StagingMetadata bool
	FileContents    bool
}

Jump to

Keyboard shortcuts

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