@@ -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.
4749var 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).
5359type OwnerMatchFunc func (s string ) (Owner , error )
5460
5561func (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.
5967func 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.
6878func 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.
7789func MatchUsernameOwner (s string ) (Owner , error ) {
7890 match := usernameRegexp .FindStringSubmatch (s )
7991 if match == nil {
0 commit comments