codeowners

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: BSD-3-Clause Imports: 11 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, fileReader FileReader, warningWriter io.Writer) (CodeOwners, error)

New creates a new CodeOwners object from a root path and a list of diff files If fileReader is nil, it will use the filesystem

type DiffFile

type DiffFile struct {
	FileName string
	Hunks    []HunkRange
}

type FileReader added in v1.6.0

type FileReader interface {
	ReadFile(path string) ([]byte, error)
	PathExists(path string) bool
}

FileReader defines an interface for reading files from different sources

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 FilesystemReader added in v1.6.0

type FilesystemReader struct{}

FilesystemReader implements FileReader for the local filesystem

func (*FilesystemReader) PathExists added in v1.6.0

func (f *FilesystemReader) PathExists(path string) bool

func (*FilesystemReader) ReadFile added in v1.6.0

func (f *FilesystemReader) ReadFile(path string) ([]byte, error)

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(includeCheckbox bool) string

type Rules

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

func Read

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

Read the .codeowners file and return the fallback owner, ownership tests, and additional ownership tests If fileReader is nil, it will use the filesystem

Jump to

Keyboard shortcuts

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