Skip to content

Commit

Permalink
Fix bug with period in org team name (#60)
Browse files Browse the repository at this point in the history
Currently if you have an org team name with a period in it, the team will not be found with a 404 response. This is because the GitHub API requires that the periods are replaced with hyphens. This PR fixes this behavior and closes #55.

Signed-off-by: Thomas Stringer <thomas@trstringer.com>
  • Loading branch information
trstringer authored Nov 11, 2022
1 parent 753e13e commit 05a49ff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion approvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ func retrieveApprovers(client *github.Client, repoOwner string) ([]string, error

func expandGroupFromUser(client *github.Client, org, userOrTeam string, workflowInitiator string, shouldExcludeWorkflowInitiator bool) []string {
fmt.Printf("Attempting to expand user %s/%s as a group (may not succeed)\n", org, userOrTeam)
users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, userOrTeam, &github.TeamListTeamMembersOptions{})

// GitHub replaces periods in the team name with hyphens. If a period is
// passed to the request it would result in a 404. So we need to replace
// and occurrences with a hyphen.
formattedUserOrTeam := strings.ReplaceAll(userOrTeam, ".", "-")

users, _, err := client.Teams.ListTeamMembersBySlug(context.Background(), org, formattedUserOrTeam, &github.TeamListTeamMembersOptions{})
if err != nil {
fmt.Printf("%v\n", err)
return nil
Expand Down

0 comments on commit 05a49ff

Please sign in to comment.