✨ feat(vscode): 摘修复按 PR 分组框选,可搜作者和标题

This commit is contained in:
cruldra committed 2026-09-01 17:27:27 +08:00
1 parent 0031851df3
commit 3e3750c494
9 files changed
+353 -42

No files matched your search

+34
View File
@@ -12,6 +12,8 @@ import {
normalizeReleasePrefix,
pickCurrentRelease,
todayReleaseBranch,
parsePrNumber,
groupCommitsByPr,
} from '../../src/git/release'
const gitEnv = { ...process.env, GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', GIT_TERMINAL_PROMPT: '0', GIT_AUTHOR_NAME: 't', GIT_AUTHOR_EMAIL: 't@t', GIT_COMMITTER_NAME: 't', GIT_COMMITTER_EMAIL: 't@t' }
@@ -56,6 +58,38 @@ describe('纯函数', () => {
expect(pickCurrentRelease('release/', ['main', 'release/2026-08-01', 'release/2026-08-31', 'hotfix/2027'])).toBe('release/2026-08-31')
expect(pickCurrentRelease('release/', ['main'])).toBeUndefined()
})
it('parsePrNumber 认 Closes/Fixes/Resolves 和 (#N)', () => {
expect(parsePrNumber('feat: x (#390)')).toBe(390)
expect(parsePrNumber('fix: y\n\nCloses #12')).toBe(12)
expect(parsePrNumber('fix: y\n\nFixes #3')).toBe(3)
expect(parsePrNumber('fix: y\n\nResolves #9')).toBe(9)
expect(parsePrNumber('feat: no pr')).toBeUndefined()
})
it('groupCommitsByPr 同 PR 收一组,无 PR 进未关联,保持新→旧', () => {
const groups = groupCommitsByPr([
{ sha: 'a', subject: 'feat: later (#2)', author: 'me', date: '2026-09-01', body: '' },
{ sha: 'b', subject: 'fix: earlier', author: 'you', date: '2026-08-31', body: 'Closes #2' },
{ sha: 'c', subject: 'chore: lone', author: 'you', date: '2026-08-30', body: '' },
])
expect(groups).toEqual([
{
pr: 2,
title: 'feat: later',
authors: ['me', 'you'],
commits: [
{ sha: 'a', subject: 'feat: later (#2)', author: 'me', date: '2026-09-01', body: '' },
{ sha: 'b', subject: 'fix: earlier', author: 'you', date: '2026-08-31', body: 'Closes #2' },
],
},
{
title: '未关联 PR',
authors: ['you'],
commits: [
{ sha: 'c', subject: 'chore: lone', author: 'you', date: '2026-08-30', body: '' },
],
},
])
})
})
describe('集成', () => {