Skip to content

Commit 7334092

Browse files
authored
Merge pull request #136 from akashivskyy/lowercase-labels
Perform case-insensitive comparison
2 parents aeb80ee + a1e8057 commit 7334092

4 files changed

Lines changed: 48 additions & 5 deletions

File tree

__tests__/add-to-project.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,49 @@ describe('addToProject', () => {
537537
projectNumber: 1
538538
})
539539
})
540+
541+
test('compares labels case-insensitively', async () => {
542+
mockGetInput({
543+
'project-url': 'https://github.com/orgs/github/projects/1',
544+
'github-token': 'gh_token',
545+
labeled: 'FOO, Bar, baz',
546+
'label-operator': 'AND'
547+
})
548+
549+
github.context.payload = {
550+
issue: {
551+
number: 1,
552+
labels: [{name: 'foo'}, {name: 'BAR'}, {name: 'baz'}]
553+
}
554+
}
555+
556+
mockGraphQL(
557+
{
558+
test: /getProject/,
559+
return: {
560+
organization: {
561+
projectNext: {
562+
id: 'project-next-id'
563+
}
564+
}
565+
}
566+
},
567+
{
568+
test: /addProjectNextItem/,
569+
return: {
570+
addProjectNextItem: {
571+
projectNextItem: {
572+
id: 'project-next-item-id'
573+
}
574+
}
575+
}
576+
}
577+
)
578+
579+
await addToProject()
580+
581+
expect(outputs.itemId).toEqual('project-next-item-id')
582+
})
540583
})
541584

542585
describe('mustGetOwnerTypeQuery', () => {

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/add-to-project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export async function addToProject(): Promise<void> {
3535
core
3636
.getInput('labeled')
3737
.split(',')
38-
.map(l => l.trim())
38+
.map(l => l.trim().toLowerCase())
3939
.filter(l => l.length > 0) ?? []
4040
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase()
4141

4242
const octokit = github.getOctokit(ghToken)
4343
const urlMatch = projectUrl.match(urlParse)
4444
const issue = github.context.payload.issue ?? github.context.payload.pull_request
45-
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name)
45+
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name.toLowerCase())
4646

4747
// Ensure the issue matches our `labeled` filter based on the label-operator.
4848
if (labelOperator === 'and') {

0 commit comments

Comments
 (0)