Skip to content

Commit

Permalink
feat: ignore case when matching yml configuration to GitHub author (#216
Browse files Browse the repository at this point in the history
)
  • Loading branch information
7PH authored Jan 3, 2024
1 parent e3dbfde commit 2511c31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions __tests__/teams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ test('Should add team label when the author is found', () => {
expect(output).toEqual(['LightSide'])
})

test('Should be able to detect users with different username casings', () => {
// Given
const author = '@Anakin'
const labelGlobs = new Map<string, string[]>()
labelGlobs.set('LightSide', ['@Yoda', '@ANAKIN'])

// When
const output = getTeamLabel(labelGlobs, author)

// Expect
expect(output).toEqual(['LightSide'])
})

test('Should be able to detect when a user is in multiple teams', () => {
// Given
const author = '@Anakin'
Expand Down
6 changes: 4 additions & 2 deletions src/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export function getTeamLabel(
author: string
): string[] {
const labels: string[] = []
for (const [label, authors] of labelsConfiguration.entries())
if (authors.includes(author)) labels.push(label)
for (const [label, authors] of labelsConfiguration.entries()) {
if (authors.some(a => a.toLowerCase() === author.toLowerCase()))
labels.push(label)
}
return labels
}

0 comments on commit 2511c31

Please sign in to comment.