Show GitHub issue assignees in the task list (#2557)
This commit is contained in:
@@ -99,7 +99,14 @@ describe('listWorkItems', () => {
|
||||
url: 'https://github.com/acme/widgets/issues/12',
|
||||
labels: [],
|
||||
updatedAt: '2026-03-29T00:00:00Z',
|
||||
author: { login: 'octocat' }
|
||||
author: { login: 'octocat' },
|
||||
assignees: [
|
||||
{
|
||||
login: 'test-assignee',
|
||||
name: 'Test Assignee',
|
||||
databaseId: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
})
|
||||
@@ -120,8 +127,8 @@ describe('listWorkItems', () => {
|
||||
reviewRequests: [
|
||||
{
|
||||
requestedReviewer: {
|
||||
login: 'AmethystLiang',
|
||||
name: 'Amethyst Liang',
|
||||
login: 'test-assignee',
|
||||
name: 'Test Assignee',
|
||||
avatarUrl: 'https://avatars.githubusercontent.com/u/1?v=4'
|
||||
}
|
||||
}
|
||||
@@ -142,7 +149,7 @@ describe('listWorkItems', () => {
|
||||
'--limit',
|
||||
'10',
|
||||
'--json',
|
||||
'number,title,state,url,labels,updatedAt,author',
|
||||
'number,title,state,url,labels,updatedAt,author,assignees',
|
||||
'--repo',
|
||||
'acme/widgets',
|
||||
'--assignee',
|
||||
@@ -180,7 +187,14 @@ describe('listWorkItems', () => {
|
||||
url: 'https://github.com/acme/widgets/issues/12',
|
||||
labels: [],
|
||||
updatedAt: '2026-03-29T00:00:00Z',
|
||||
author: 'octocat'
|
||||
author: 'octocat',
|
||||
assignees: [
|
||||
{
|
||||
login: 'test-assignee',
|
||||
name: 'Test Assignee',
|
||||
avatarUrl: 'https://avatars.githubusercontent.com/u/1?v=4'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'pr:42',
|
||||
@@ -198,8 +212,8 @@ describe('listWorkItems', () => {
|
||||
prRepo: { owner: 'acme', repo: 'widgets' },
|
||||
reviewRequests: [
|
||||
{
|
||||
login: 'AmethystLiang',
|
||||
name: 'Amethyst Liang',
|
||||
login: 'test-assignee',
|
||||
name: 'Test Assignee',
|
||||
avatarUrl: 'https://avatars.githubusercontent.com/u/1?v=4'
|
||||
}
|
||||
]
|
||||
@@ -453,7 +467,7 @@ describe('listWorkItems', () => {
|
||||
'--limit',
|
||||
'10',
|
||||
'--json',
|
||||
'number,title,state,url,labels,updatedAt,author',
|
||||
'number,title,state,url,labels,updatedAt,author,assignees',
|
||||
'--repo',
|
||||
'acme/widgets',
|
||||
'--state',
|
||||
|
||||
@@ -331,6 +331,8 @@ export async function getAuthenticatedViewer(): Promise<GitHubViewer | null> {
|
||||
// single-repo and cross-repo items are uniform downstream.
|
||||
type MainWorkItem = Omit<GitHubWorkItem, 'repoId'>
|
||||
|
||||
const WORK_ITEM_ISSUE_LIST_JSON_FIELDS = 'number,title,state,url,labels,updatedAt,author,assignees'
|
||||
|
||||
const WORK_ITEM_PR_LIST_JSON_FIELDS =
|
||||
'number,title,state,url,labels,updatedAt,author,isDraft,headRefName,baseRefName,headRefOid,headRepositoryOwner,reviewRequests'
|
||||
|
||||
@@ -364,7 +366,8 @@ function mapIssueWorkItem(item: Record<string, unknown>): MainWorkItem {
|
||||
? String((item.user as { login?: unknown }).login ?? '')
|
||||
: typeof item.author === 'object' && item.author !== null && 'login' in item.author
|
||||
? String((item.author as { login?: unknown }).login ?? '')
|
||||
: null
|
||||
: null,
|
||||
...(item.assignees !== undefined ? { assignees: usersFromUnknown(item.assignees) } : {})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,6 +426,7 @@ function userFromUnknown(
|
||||
if (!login) {
|
||||
return null
|
||||
}
|
||||
const databaseId = numberFromUnknown(raw.databaseId)
|
||||
return {
|
||||
login,
|
||||
name: typeof raw.name === 'string' ? raw.name : null,
|
||||
@@ -431,7 +435,9 @@ function userFromUnknown(
|
||||
? raw.avatarUrl
|
||||
: typeof raw.avatar_url === 'string'
|
||||
? raw.avatar_url
|
||||
: ''
|
||||
: databaseId !== undefined
|
||||
? `https://avatars.githubusercontent.com/u/${databaseId}?v=4`
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,10 +713,7 @@ function buildWorkItemListArgs(args: {
|
||||
before?: string
|
||||
}): string[] {
|
||||
const { kind, ownerRepo, limit, query, before } = args
|
||||
const fields =
|
||||
kind === 'issue'
|
||||
? 'number,title,state,url,labels,updatedAt,author'
|
||||
: WORK_ITEM_PR_LIST_JSON_FIELDS
|
||||
const fields = kind === 'issue' ? WORK_ITEM_ISSUE_LIST_JSON_FIELDS : WORK_ITEM_PR_LIST_JSON_FIELDS
|
||||
const command = kind === 'issue' ? ['issue', 'list'] : ['pr', 'list']
|
||||
const out = [...command, '--limit', String(limit), '--json', fields]
|
||||
|
||||
@@ -828,7 +831,7 @@ async function listRecentWorkItems(
|
||||
'--state',
|
||||
'open',
|
||||
'--json',
|
||||
'number,title,state,url,labels,updatedAt,author'
|
||||
WORK_ITEM_ISSUE_LIST_JSON_FIELDS
|
||||
],
|
||||
ghOptions
|
||||
),
|
||||
@@ -924,7 +927,7 @@ async function listRecentWorkItems(
|
||||
'--state',
|
||||
'open',
|
||||
'--json',
|
||||
'number,title,state,url,labels,updatedAt,author'
|
||||
WORK_ITEM_ISSUE_LIST_JSON_FIELDS
|
||||
],
|
||||
ghOptions
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user