codeowners

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeOwners

type CodeOwners interface {
	// SetAuthor sets the author of the PR
	SetAuthor(author string)

	// FileRequired returns a map of file names to their required reviewers
	FileRequired() map[string]ReviewerGroups

	// FileReviewers returns a map of file names to their required reviewers
	FileOptional() map[string]ReviewerGroups

	// AllRequired returns a list of the required reviewers for all files in the PR
	AllRequired() ReviewerGroups

	// AllOptional return a list of the optional reviewers for all files in the PR
	AllOptional() ReviewerGroups

	// UnownedFiles returns a list of files in the diff which are not
	UnownedFiles() []string

	// ApplyApprovals marks the given approvers as satisfied
	ApplyApprovals(approvers []string)
}

CodeOwners represents a collection of owned files, with reverse lookups for owners and reviewers

func New

func New(root string, files []DiffFile, warningWriter io.Writer) (CodeOwners, error)

New creates a new CodeOwners object from a root path and a list of diff files

type DiffFile

type DiffFile struct {
	FileName string
	Hunks    []HunkRange
}

type FileTestCases

type FileTestCases []*reviewerTest

func (FileTestCases) Len

func (ftc FileTestCases) Len() int

func (FileTestCases) Less

func (ftc FileTestCases) Less(i, j int) bool

func (FileTestCases) Swap

func (ftc FileTestCases) Swap(i, j int)

type HunkRange

type HunkRange struct {
	Start int
	End   int
}

type ReviewerGroup

type ReviewerGroup struct {
	Names    []string
	Approved bool
}

Represents a group of ReviewerGroup, with a list of names and an approved status

func (*ReviewerGroup) ToCommentString

func (rg *ReviewerGroup) ToCommentString() string

type ReviewerGroupManager

type ReviewerGroupManager interface {
	ToReviewerGroup(names ...string) *ReviewerGroup
}

func NewReviewerGroupMemo

func NewReviewerGroupMemo() ReviewerGroupManager

type ReviewerGroupMemo

type ReviewerGroupMemo map[string]*ReviewerGroup

func (ReviewerGroupMemo) ToReviewerGroup

func (rgm ReviewerGroupMemo) ToReviewerGroup(names ...string) *ReviewerGroup

Create a new Reviewers, memoizing the Reviewers so it is only created once

type ReviewerGroups

type ReviewerGroups []*ReviewerGroup

func (ReviewerGroups) FilterOut

func (rgs ReviewerGroups) FilterOut(names ...string) ReviewerGroups

func (ReviewerGroups) Flatten

func (rgs ReviewerGroups) Flatten() []string

func (ReviewerGroups) ToCommentString

func (rgs ReviewerGroups) ToCommentString() string

type Rules

type Rules struct {
	Fallback                *ReviewerGroup
	OwnerTests              FileTestCases
	AdditionalReviewerTests FileTestCases
	OptionalReviewerTests   FileTestCases
}

func Read

func Read(path string, reviewerGroupManager ReviewerGroupManager, warningWriter io.Writer) Rules

Read the .codeowners file and return the fallback owner, ownership tests, and additional ownership tests

Jump to

Keyboard shortcuts

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