Skip to content

Commit 638725f

Browse files
authored
Merge pull request #140 from JasonEtco/fix-search-all
Don't include `is:all` in issue filter
2 parents a2b2af1 + 277e9c1 commit 638725f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/action.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function logError(tools: Toolkit, template: string, action: 'creating' | 'updati
2323
export async function createAnIssue (tools: Toolkit) {
2424
const template = tools.inputs.filename || '.github/ISSUE_TEMPLATE.md'
2525
const assignees = tools.inputs.assignees
26-
const searchExistingType = tools.inputs.search_existing || 'open'
2726

2827
let updateExisting: Boolean | null = null
2928
if (tools.inputs.update_existing) {
@@ -62,9 +61,16 @@ export async function createAnIssue (tools: Toolkit) {
6261

6362
if (updateExisting !== null) {
6463
tools.log.info(`Fetching issues with title "${templated.title}"`)
65-
const existingIssues = await tools.github.search.issuesAndPullRequests({
66-
q: `is:${searchExistingType} is:issue repo:${process.env.GITHUB_REPOSITORY} in:title ${templated.title}`
67-
})
64+
65+
let query = `is:issue repo:${process.env.GITHUB_REPOSITORY} in:title ${templated.title}`
66+
67+
const searchExistingType = tools.inputs.search_existing || 'open'
68+
const allowedStates = ['open', 'closed']
69+
if (allowedStates.includes(searchExistingType)) {
70+
query += ` is:${searchExistingType}`
71+
}
72+
73+
const existingIssues = await tools.github.search.issuesAndPullRequests({ q: query })
6874
const existingIssue = existingIssues.data.items.find(issue => issue.title === templated.title)
6975
if (existingIssue) {
7076
if (updateExisting === false) {

tests/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe('create-an-issue', () => {
193193
const q = parsedQuery['q']
194194
if (typeof(q) === 'string') {
195195
const args = q.split(' ')
196-
return args.includes('is:all') && args.includes('is:issue')
196+
return !args.includes('is:all') && args.includes('is:issue')
197197
} else {
198198
return false
199199
}

0 commit comments

Comments
 (0)