mirror of
https://github.com/actions/add-to-project.git
synced 2025-12-11 20:47:05 +00:00
Merge pull request #136 from akashivskyy/lowercase-labels
Perform case-insensitive comparison
This commit is contained in:
@@ -537,6 +537,49 @@ describe('addToProject', () => {
|
|||||||
projectNumber: 1
|
projectNumber: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('compares labels case-insensitively', async () => {
|
||||||
|
mockGetInput({
|
||||||
|
'project-url': 'https://github.com/orgs/github/projects/1',
|
||||||
|
'github-token': 'gh_token',
|
||||||
|
labeled: 'FOO, Bar, baz',
|
||||||
|
'label-operator': 'AND'
|
||||||
|
})
|
||||||
|
|
||||||
|
github.context.payload = {
|
||||||
|
issue: {
|
||||||
|
number: 1,
|
||||||
|
labels: [{name: 'foo'}, {name: 'BAR'}, {name: 'baz'}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mockGraphQL(
|
||||||
|
{
|
||||||
|
test: /getProject/,
|
||||||
|
return: {
|
||||||
|
organization: {
|
||||||
|
projectNext: {
|
||||||
|
id: 'project-next-id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /addProjectNextItem/,
|
||||||
|
return: {
|
||||||
|
addProjectNextItem: {
|
||||||
|
projectNextItem: {
|
||||||
|
id: 'project-next-item-id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
await addToProject()
|
||||||
|
|
||||||
|
expect(outputs.itemId).toEqual('project-next-item-id')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mustGetOwnerTypeQuery', () => {
|
describe('mustGetOwnerTypeQuery', () => {
|
||||||
|
|||||||
4
dist/index.js
generated
vendored
4
dist/index.js
generated
vendored
@@ -53,13 +53,13 @@ function addToProject() {
|
|||||||
const labeled = (_a = core
|
const labeled = (_a = core
|
||||||
.getInput('labeled')
|
.getInput('labeled')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(l => l.trim())
|
.map(l => l.trim().toLowerCase())
|
||||||
.filter(l => l.length > 0)) !== null && _a !== void 0 ? _a : [];
|
.filter(l => l.length > 0)) !== null && _a !== void 0 ? _a : [];
|
||||||
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase();
|
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase();
|
||||||
const octokit = github.getOctokit(ghToken);
|
const octokit = github.getOctokit(ghToken);
|
||||||
const urlMatch = projectUrl.match(urlParse);
|
const urlMatch = projectUrl.match(urlParse);
|
||||||
const issue = (_b = github.context.payload.issue) !== null && _b !== void 0 ? _b : github.context.payload.pull_request;
|
const issue = (_b = github.context.payload.issue) !== null && _b !== void 0 ? _b : github.context.payload.pull_request;
|
||||||
const issueLabels = ((_c = issue === null || issue === void 0 ? void 0 : issue.labels) !== null && _c !== void 0 ? _c : []).map((l) => l.name);
|
const issueLabels = ((_c = issue === null || issue === void 0 ? void 0 : issue.labels) !== null && _c !== void 0 ? _c : []).map((l) => l.name.toLowerCase());
|
||||||
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
||||||
if (labelOperator === 'and') {
|
if (labelOperator === 'and') {
|
||||||
if (!labeled.every(l => issueLabels.includes(l))) {
|
if (!labeled.every(l => issueLabels.includes(l))) {
|
||||||
|
|||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -35,14 +35,14 @@ export async function addToProject(): Promise<void> {
|
|||||||
core
|
core
|
||||||
.getInput('labeled')
|
.getInput('labeled')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(l => l.trim())
|
.map(l => l.trim().toLowerCase())
|
||||||
.filter(l => l.length > 0) ?? []
|
.filter(l => l.length > 0) ?? []
|
||||||
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase()
|
const labelOperator = core.getInput('label-operator').trim().toLocaleLowerCase()
|
||||||
|
|
||||||
const octokit = github.getOctokit(ghToken)
|
const octokit = github.getOctokit(ghToken)
|
||||||
const urlMatch = projectUrl.match(urlParse)
|
const urlMatch = projectUrl.match(urlParse)
|
||||||
const issue = github.context.payload.issue ?? github.context.payload.pull_request
|
const issue = github.context.payload.issue ?? github.context.payload.pull_request
|
||||||
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name)
|
const issueLabels: string[] = (issue?.labels ?? []).map((l: {name: string}) => l.name.toLowerCase())
|
||||||
|
|
||||||
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
// Ensure the issue matches our `labeled` filter based on the label-operator.
|
||||||
if (labelOperator === 'and') {
|
if (labelOperator === 'and') {
|
||||||
|
|||||||
Reference in New Issue
Block a user