Skip to content

Commit 2eb5d72

Browse files
team: Add a convenience function to find people by their Github name
1 parent 2ec8a43 commit 2eb5d72

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pkg/team/team.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,23 @@ func Load(peopleYAML, teamYAML io.Reader) ([]Person, error) {
7474
return people, nil
7575
}
7676

77-
// The boolean is false if no team member was found with that Jira name.
77+
// PersonByJiraName returns the first person in the slice with the given Jira
78+
// name. The returned boolean is false if not found.
7879
func PersonByJiraName(people []Person, jiraName string) (Person, bool) {
79-
for _, person := range people {
80-
if person.Jira == jiraName {
81-
return person, true
80+
for i := range people {
81+
if people[i].Jira == jiraName {
82+
return people[i], true
83+
}
84+
}
85+
return Person{}, false
86+
}
87+
88+
// PersonByGithubHandle returns the first person in the slice with the given
89+
// Github handle. The returned boolean is false if not found.
90+
func PersonByGithubHandle(people []Person, githubHandle string) (Person, bool) {
91+
for i := range people {
92+
if people[i].Github == githubHandle {
93+
return people[i], true
8294
}
8395
}
8496
return Person{}, false

0 commit comments

Comments
 (0)