mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
feat(tasks): filter GitHub tasks by several authors (#42450)
* feat(tasks): filter GitHub tasks by several authors * fix(tasks): keep author candidates across picks * refactor(tasks): share author filter summary and only-me check
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseTaskQuery } from '../../../../shared/work-items/task-query'
|
||||
import { buildWorkItemListRequest } from './work-item-list-request'
|
||||
|
||||
const ownerRepo = { owner: 'acme', repo: 'widgets' }
|
||||
|
||||
describe('buildWorkItemListRequest', () => {
|
||||
it('ORs several authors in the grammar each GitHub search understands', () => {
|
||||
const query = parseTaskQuery('is:open author:alice author:bob')
|
||||
const issues = buildWorkItemListRequest({ kind: 'issue', ownerRepo, limit: 20, query, page: 1 })
|
||||
const prs = buildWorkItemListRequest({ kind: 'pr', ownerRepo, limit: 20, query, page: 1 })
|
||||
|
||||
expect(issues.search).toBe('repo:acme/widgets is:issue is:open author:alice author:bob')
|
||||
expect(prs.search).toBe(
|
||||
'( is:open (author:alice OR author:bob) sort:created-desc ) repo:acme/widgets type:pr'
|
||||
)
|
||||
expect(prs.args.at(prs.args.indexOf('--search') + 1)).toBe(
|
||||
'is:open (author:alice OR author:bob) sort:created-desc'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -54,8 +54,12 @@ export function buildWorkItemListRequest(args: {
|
||||
if (query.assignee) {
|
||||
searchParts.push(`assignee:${quoteGitHubSearchValue(query.assignee)}`)
|
||||
}
|
||||
if (query.author) {
|
||||
searchParts.push(`author:${quoteGitHubSearchValue(query.author)}`)
|
||||
const authorTerms = query.authors.map((author) => `author:${quoteGitHubSearchValue(author)}`)
|
||||
// search/issues ORs repeated author:, but gh pr list's advanced search ANDs them.
|
||||
if (kind === 'pr' && authorTerms.length > 1) {
|
||||
searchParts.push(`(${authorTerms.join(' OR ')})`)
|
||||
} else {
|
||||
searchParts.push(...authorTerms)
|
||||
}
|
||||
if (query.labels.length > 0) {
|
||||
for (const label of query.labels) {
|
||||
|
||||
@@ -29,8 +29,8 @@ export function buildSearchQueryString(
|
||||
if (query.assignee) {
|
||||
parts.push(`assignee:${quoteGitHubSearchValue(query.assignee)}`)
|
||||
}
|
||||
if (query.author) {
|
||||
parts.push(`author:${quoteGitHubSearchValue(query.author)}`)
|
||||
for (const author of query.authors) {
|
||||
parts.push(`author:${quoteGitHubSearchValue(author)}`)
|
||||
}
|
||||
if (query.reviewRequested) {
|
||||
parts.push(`review-requested:${quoteGitHubSearchValue(query.reviewRequested)}`)
|
||||
@@ -57,7 +57,7 @@ export function defaultOpenWorkItemQuery(): ParsedTaskQuery {
|
||||
state: 'open',
|
||||
draft: false,
|
||||
assignee: null,
|
||||
author: null,
|
||||
authors: [],
|
||||
reviewRequested: null,
|
||||
reviewedBy: null,
|
||||
labels: [],
|
||||
|
||||
Reference in New Issue
Block a user