codeowners

package
v0.0.0-...-ec47783 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(content string) (CST, Anomalies)

Parse parses the content of a CODEOWNERS file and returns a CST (and a list of syntax errors and other anomalies)

Types

type Anomalies

type Anomalies []Anomaly

Anomalies is a collection of problems in a CODEOWNERS file

func (Anomalies) String

func (anomalies Anomalies) String() string

type Anomaly

type Anomaly struct {
	LineNo int    `json:"lineNo"`
	Reason string `json:"reason"`
	Raw    string `json:"raw"`
}

Anomaly represents a problem in a CODEOWNERS file

func (Anomaly) String

func (anomaly Anomaly) String() string

type CST

type CST []Line

CST represents the Concrete Syntax Tree of a CODEOWNERS file

func (CST) Format

func (cst CST) Format(headerComment string) (string, error)

Format returns the cst as a string in CODEOWNERS format.

type Line

type Line struct {
	// rule, section-heading, comment, ignorable-comment, empty, unknown,
	Type   string `json:"type"`
	LineNo int    `json:"lineNo"`
	Raw    string `json:"raw"`

	// rule only
	RulePattern string `json:"rulePattern"`
	RuleSection string `json:"ruleSection"`

	// section heading
	SectionOptional     bool   `json:"sectionOptional"`
	SectionName         string `json:"sectionName"`
	SectionMinApprovers int    `json:"sectionMinApprovers"`

	// rule and section heading
	Spaces        string  `json:"spaces"`
	Owners        []Owner `json:"owners"`
	InlineComment string  `json:"inlineComment"`
}

Line represents a line in a CODEOWNERS file

func (Line) String

func (line Line) String() string

type Owner

type Owner struct {
	// user-or-group, e-mail, invalid
	Type string `json:"type"`
	Name string `json:"name"`
}

Owner represents an owner in rule or section-heading

Types:

  • "user-or-group" (these start with an "@" symbol e.g. @john_doe or @the_a_team)
  • "e-mail" (e-mail addresses. We're not checking against the entire RFC 5322, just a simple check for presence of an "@" symbol)
  • "invalid" (anything else)

func ParseOwner

func ParseOwner(owner string) Owner

Jump to

Keyboard shortcuts

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