✨ feat(vscode): 摘修复可按作者筛选,高亮发布点后第一条

This commit is contained in:
cruldra committed 2026-09-01 19:15:32 +08:00
1 parent 54fc2ead4c
commit beb7750eac
9 files changed
+137 -33

No files matched your search

@@ -0,0 +1,37 @@
import { describe, expect, it } from 'vitest'
import type { ReleaseCommitGroup } from './messages'
import { filterCherryPickGroups, uniqueAuthors } from './cherryPickView'
const groups: ReleaseCommitGroup[] = [
{
title: '未关联 PR',
authors: ['cruldra'],
commits: [
{ sha: 'a', subject: 'chore: lone', author: 'cruldra', date: '2026-09-01', body: '' },
],
},
{
pr: 260,
title: '连续包月',
authors: ['chehongweo', 'cruldra'],
commits: [
{ sha: 'b', subject: 'fix: admin', author: 'chehongweo', date: '2026-08-31', body: '' },
{ sha: 'c', subject: 'fix: membership', author: 'cruldra', date: '2026-08-30', body: '' },
],
},
]
describe('filterCherryPickGroups', () => {
it('只勾选的作者才出现', () => {
const out = filterCherryPickGroups(groups, '', new Set(['chehongweo']))
expect(out).toHaveLength(1)
expect(out[0].pr).toBe(260)
expect(out[0].commits.map(c => c.sha)).toEqual(['b'])
})
})
describe('uniqueAuthors', () => {
it('按出现顺序去重', () => {
expect(uniqueAuthors(groups)).toEqual(['cruldra', 'chehongweo'])
})
})
@@ -0,0 +1,47 @@
import type { ReleaseCommitGroup } from './messages'
export function uniqueAuthors(groups: ReleaseCommitGroup[]): string[] {
const out: string[] = []
for (const g of groups) {
for (const a of g.authors) {
if (!out.includes(a))
out.push(a)
}
}
return out
}
export function filterCherryPickGroups(
groups: ReleaseCommitGroup[],
query: string,
authors: ReadonlySet<string>,
): ReleaseCommitGroup[] {
const q = query.trim().toLowerCase()
const out: ReleaseCommitGroup[] = []
for (const g of groups) {
const commits = g.commits.filter(c => authors.has(c.author))
if (commits.length === 0)
continue
if (!q) {
out.push({ ...g, authors: uniqueAuthors([{ ...g, commits }]), commits })
continue
}
const head = `#${g.pr ?? ''} ${g.title} ${g.authors.join(' ')}`.toLowerCase()
if (head.includes(q)) {
out.push({ ...g, authors: uniqueAuthors([{ ...g, commits }]), commits })
continue
}
const hit = commits.filter(c =>
`${c.subject} ${c.author} ${c.sha} ${c.date}`.toLowerCase().includes(q),
)
if (hit.length > 0)
out.push({ ...g, authors: uniqueAuthors([{ ...g, commits: hit }]), commits: hit })
}
return out
}
export function groupContainingSha(groups: ReleaseCommitGroup[], sha: string | undefined): ReleaseCommitGroup | undefined {
if (!sha)
return undefined
return groups.find(g => g.commits.some(c => c.sha === sha))
}
+1 -1
View File
@@ -153,7 +153,7 @@ export type ExtensionToWebview
running: boolean
jenkinsConfigured: boolean
}
| { type: 'release/pick-show', branch: string, groups: ReleaseCommitGroup[] }
| { type: 'release/pick-show', branch: string, groups: ReleaseCommitGroup[], firstAfterReleaseSha?: string }
| { type: 'env-lock/status', locked: boolean, fileCount: number, failedCount?: number }
| { type: 'issue/remove', issueNumber: number }
| { type: 'profiles/show', data: ProfilesData }