codeowners

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("file not found")

	ErrFileParseInvalidEscapingInPattern = errors.New(
		"a pattern requires '\\' to be escaped with another '\\', or used to escape control characters " +
			"[space, tab, '#'] or any of the available special characters " +
			"['*', '?', '[', ']', '{', '}', '-', '!', '^']",
	)
	ErrFileParseTrailingBackslashInPattern = errors.New("a pattern can't end with a trailing '\\'")
)

Functions

This section is empty.

Types

type CodeOwners

type CodeOwners struct {
	FileSHA string
	Entries []Entry
}

type Config

type Config struct {
	FilePaths []string
}

type Entry

type Entry struct {
	// LineNumber is the line number of the code owners entry.
	LineNumber int64

	// Pattern is a glob star pattern used to match the entry against a given file path.
	Pattern string
	// Owners is the list of owners for the given pattern.
	// NOTE: Could be empty in case of an entry that clears previously defined ownerships.
	Owners []string
}

func (*Entry) IsOwnershipReset

func (e *Entry) IsOwnershipReset() bool

IsOwnershipReset returns true iff the entry resets any previously defined ownerships.

type Evaluation

type Evaluation struct {
	EvaluationEntries []EvaluationEntry
	FileSha           string
}

type EvaluationEntry

type EvaluationEntry struct {
	LineNumber                int64
	Pattern                   string
	OwnerEvaluations          []OwnerEvaluation
	UserGroupOwnerEvaluations []UserGroupOwnerEvaluation
}

type File

type File struct {
	Content   string
	SHA       string
	TotalSize int64
}

type FileParseError

type FileParseError struct {
	LineNumber int64
	Line       string
	Err        error
}

FileParseError represents an error if codeowners file is not parsable.

func (*FileParseError) Error

func (e *FileParseError) Error() string

func (*FileParseError) Is

func (e *FileParseError) Is(target error) bool

func (*FileParseError) Unwrap

func (e *FileParseError) Unwrap() error

type OwnerEvaluation

type OwnerEvaluation struct {
	Owner          types.PrincipalInfo
	ReviewDecision enum.PullReqReviewDecision
	ReviewSHA      string
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(
	repoStore store.RepoStore,
	git git.Interface,
	config Config,
	principalStore store.PrincipalStore,
	userGroupResolver usergroup.Resolver,
) *Service

func ProvideCodeOwners

func ProvideCodeOwners(
	git git.Interface,
	repoStore store.RepoStore,
	config Config,
	principalStore store.PrincipalStore,
	userGroupResolver usergroup.Resolver,
) *Service

func (*Service) Evaluate

func (s *Service) Evaluate(
	ctx context.Context,
	repo *types.Repository,
	pr *types.PullReq,
	reviewers []*types.PullReqReviewer,
) (*Evaluation, error)

func (*Service) Validate

func (s *Service) Validate(
	ctx context.Context,
	repo *types.Repository,
	branch string,
) (*types.CodeOwnersValidation, error)

func (*Service) ValidateCodeOwnerByPush

func (s *Service) ValidateCodeOwnerByPush(
	ctx context.Context,
	repo *types.Repository,
	uid int64,
	ref hook.ReferenceUpdate,
	objDir []string,
) ([]Entry, error)

type TooLargeError

type TooLargeError struct {
	FileSize int64
}

TooLargeError represents an error if codeowners file is too large.

func (*TooLargeError) Error

func (e *TooLargeError) Error() string

func (*TooLargeError) Is

func (e *TooLargeError) Is(target error) bool

type UserGroupOwnerEvaluation

type UserGroupOwnerEvaluation struct {
	Identifier  string
	Name        string
	Evaluations []OwnerEvaluation
}

Jump to

Keyboard shortcuts

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