Skip to content

Commit 8e52b4a

Browse files
committed
add more docs for owner matchers
1 parent 3c5d2b8 commit 8e52b4a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

parse.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,26 @@ var (
4444
usernameRegexp = regexp.MustCompile(`\A@([a-zA-Z0-9\-_]+)\z`)
4545
)
4646

47+
// DefaultOwnerMatchers is the default set of owner matchers, which includes the
48+
// GitHub-flavored email, team, and username matchers.
4749
var DefaultOwnerMatchers = []OwnerMatcher{
4850
OwnerMatchFunc(MatchEmailOwner),
4951
OwnerMatchFunc(MatchTeamOwner),
5052
OwnerMatchFunc(MatchUsernameOwner),
5153
}
5254

55+
// OwnerMatchFunc is a function that matches a string against a pattern and
56+
// returns an Owner, or ErrNoMatch if no match was found. It implements the
57+
// OwnerMatcher interface and may be provided to WithOwnerMatchers to customize
58+
// owner matching behavior (e.g. to support GitLab-style team names).
5359
type OwnerMatchFunc func(s string) (Owner, error)
5460

5561
func (f OwnerMatchFunc) Match(s string) (Owner, error) {
5662
return f(s)
5763
}
5864

65+
// MatchEmailOwner matches an email address owner. May be provided to
66+
// WithOwnerMatchers.
5967
func MatchEmailOwner(s string) (Owner, error) {
6068
match := emailRegexp.FindStringSubmatch(s)
6169
if match == nil {
@@ -65,6 +73,8 @@ func MatchEmailOwner(s string) (Owner, error) {
6573
return Owner{Value: match[0], Type: EmailOwner}, nil
6674
}
6775

76+
// MatchTeamOwner matches a GitHub team owner. May be provided to
77+
// WithOwnerMatchers.
6878
func MatchTeamOwner(s string) (Owner, error) {
6979
match := teamRegexp.FindStringSubmatch(s)
7080
if match == nil {
@@ -74,6 +84,8 @@ func MatchTeamOwner(s string) (Owner, error) {
7484
return Owner{Value: match[1], Type: TeamOwner}, nil
7585
}
7686

87+
// MatchUsernameOwner matches a GitHub username owner. May be provided to
88+
// WithOwnerMatchers.
7789
func MatchUsernameOwner(s string) (Owner, error) {
7890
match := usernameRegexp.FindStringSubmatch(s)
7991
if match == nil {

0 commit comments

Comments
 (0)