Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codeowner ¶
Codeowner - owners for a given pattern
func NewCodeowner ¶
NewCodeowner -
type Codeowners ¶
type Codeowners struct { Patterns []Codeowner // contains filtered or unexported fields }
Codeowners - patterns/owners mappings for the given repo
func EmptyCodeowners ¶
func EmptyCodeowners() *Codeowners
EmptyCodeowners - create an empty codeowners file
func FromFile ¶
func FromFile(path string) (*Codeowners, error)
FromFile creates a Codeowners from the path to a local file.
Example ¶
c, _ := FromFile(cwd()) fmt.Println(c.Patterns[0])
Output: * @hairyhenderson
func FromReader ¶
func FromReader(r io.Reader, repoRoot string) (*Codeowners, error)
FromReader creates a Codeowners from a given Reader instance and root path.
Example ¶
reader := strings.NewReader(sample2) c, _ := FromReader(reader, "") fmt.Println(c.Patterns[0])
Output: * @hairyhenderson
func NewCodeowners
deprecated
func NewCodeowners(path string) (*Codeowners, error)
Deprecated: Use FromFile(path) instead.
func (*Codeowners) AddPattern ¶
func (c *Codeowners) AddPattern(pattern string, owners []string) (err error)
AddPattern - add a new pattern to the codeowners file
func (*Codeowners) LocalOwners ¶
func (c *Codeowners) LocalOwners(path string) []string
LocalOwners - return the list of code owners for the given path excluding the global owners (within the repo root)
func (*Codeowners) Owners ¶
func (c *Codeowners) Owners(path string) []string
Owners - return the list of code owners for the given path (within the repo root)
Example ¶
c, _ := FromFile(cwd()) owners := c.Owners("README.md") for i, o := range owners { fmt.Printf("Owner #%d is %s\n", i, o) }
Output: Owner #0 is @hairyhenderson
func (*Codeowners) ToFile ¶
func (c *Codeowners) ToFile(path string) (err error)
ToFile - serialize the Codeowners to file