Documentation
¶
Index ¶
- func ContainsSlug(slugs []Slug, target Slug) bool
- func NormalizedStrings(slugs []Slug) []string
- func OriginalStrings(slugs []Slug) []string
- type CodeOwners
- type DiffFile
- type FileReader
- type FileTestCases
- type FilesystemReader
- type HunkRange
- type ReviewerGroup
- type ReviewerGroupManager
- type ReviewerGroupMemo
- type ReviewerGroups
- type Rules
- type Slug
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsSlug ¶ added in v1.6.1
ContainsSlug checks if a Slug is in a slice (case-insensitive).
func NormalizedStrings ¶ added in v1.6.1
NormalizedStrings extracts normalized strings from Slug slice. Use for comparisons with legacy code, generic functions (Intersection, Filtered).
func OriginalStrings ¶ added in v1.6.1
OriginalStrings extracts original strings from Slug slice. Use at boundaries: API calls, comments, display.
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 []Slug)
}
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 FileReader ¶ added in v1.6.0
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
type ReviewerGroup ¶
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) ContainsAny ¶ added in v1.6.1
func (rgs ReviewerGroups) ContainsAny(names []Slug) bool
ContainsAny returns true if any of the provided names (case-insensitive) are present in any of the reviewer groups
func (ReviewerGroups) FilterOut ¶
func (rgs ReviewerGroups) FilterOut(names ...Slug) ReviewerGroups
func (ReviewerGroups) Flatten ¶
func (rgs ReviewerGroups) Flatten() []Slug
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
type Slug ¶ added in v1.6.1
type Slug struct {
// contains filtered or unexported fields
}
Slug represents a GitHub username or team name (handle) with case-insensitive semantics. It stores both the original representation (for display/API calls) and normalized form (for comparisons). The zero value is not valid - use NewSlug to construct.
GitHub uses "slug" as the canonical term for handles that work for both users and teams.
func FilterOutNames ¶ added in v1.6.1
FilterOutNames returns a new slice with names from 'names' that are NOT present in 'exclude' (case-insensitive comparison)
func NewSlug ¶ added in v1.6.1
NewSlug creates a Slug from a string, normalizing it for comparison. The original casing is preserved for display purposes.
func (Slug) EqualsString ¶ added in v1.6.1
EqualsString performs case-insensitive comparison with a string. Provided for convenience during migration and at boundaries.
func (Slug) MarshalJSON ¶ added in v1.6.1
MarshalJSON implements json.Marshaler for GitHub API compatibility. Serializes as the original string to preserve case.
func (Slug) Normalized ¶ added in v1.6.1
Normalized returns the lowercase normalized form. Use this for map keys and comparisons with legacy code.