Help us shape the future of Go! Take the 2026 Go Developer Survey

codeowners

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 9 Imported by: 18

README

CircleCI

go-codeowners

A package that finds and parses CODEOWNERS files.

Features:

  • operates on local repos
  • doesn't require a cloned repo (i.e. doesn't need a .git directory to be present at the repo's root)
  • can be called from within a repo (doesn't have to be at the root)
  • will find CODEOWNERS files in all documented locations: the repo's root, docs/, and .github/ (or .gitlab/ for GitLab repos)

Usage

go get -u github.com/hairyhenderson/go-codeowners

To find the owner of the README.md file:

import "github.com/hairyhenderson/go-codeowners"

func main() {
	c, _ := NewCodeowners(cwd())
	owners := c.Owners("README.md")
	for i, o := range owners {
		fmt.Printf("Owner #%d is %s\n", i, o)
	}
}

License

The MIT License

Copyright (c) 2018 Dave Henderson

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codeowner

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

Codeowner - owners for a given pattern

func NewCodeowner

func NewCodeowner(pattern string, owners []string) (Codeowner, error)

NewCodeowner -

func (Codeowner) String

func (c Codeowner) String() string

type Codeowners

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

Codeowners - patterns/owners mappings for the given repo

func NewCodeowners

func NewCodeowners(path string) (*Codeowners, error)

NewCodeowners -

Example
c, _ := NewCodeowners(cwd())
fmt.Println(c.patterns[0])
Output:
*	@hairyhenderson

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, _ := NewCodeowners(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

Jump to

Keyboard shortcuts

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