Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(release): generate notes from mainline PR merges

Steven Enamakelf9a0fc9622ff
diff --git a/scripts/__tests__/generate-release-notes.test.mjs b/scripts/__tests__/generate-release-notes.test.mjs
index bcae38897f..1e5e331d0a 100644
--- a/scripts/__tests__/generate-release-notes.test.mjs
+++ b/scripts/__tests__/generate-release-notes.test.mjs
@@ -44,6 +44,44 @@ test('pull request numbers preserve all linked PRs and pick the last as primary'
'abc123def456\x1ffeat(voice): global push-to-talk hotkey (#3090) (#3349)\x1fCodeGhost21\[email protected]\x1f2026-06-01T00:00:00Z\x1e',
);
assert.equal(commit.primaryPrNumber, 3349);
+ assert.deepEqual(extractPullRequestNumbers('Merge pull request #6638 from contributor/feature'), [6638]);
+});
+
+test('release notes collect only first-parent pull request merges', async (t) => {
+ const repo = mkdtempSync(join(tmpdir(), 'release-notes-merges-'));
+ t.after(() => rmSync(repo, { recursive: true, force: true }));
+ const git = (...args) => execFileSync('git', args, {
+ cwd: repo,
+ encoding: 'utf8',
+ env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' },
+ });
+ git('init', '--quiet', '--initial-branch', 'main');
+ git('config', 'user.name', 'Range Fixture');
+ git('config', 'user.email', '[email protected]');
+ git('config', 'commit.gpgsign', 'false');
+ git('commit', '--allow-empty', '--quiet', '-m', 'base');
+ git('tag', 'start');
+ git('switch', '--quiet', '-c', 'feature');
+ git('commit', '--allow-empty', '--quiet', '-m', 'feat: branch change (#100)');
+ git('switch', '--quiet', '-c', 'nested-feature');
+ git('commit', '--allow-empty', '--quiet', '-m', 'feat: nested branch change (#99)');
+ git('switch', '--quiet', 'feature');
+ git('merge', '--quiet', '--no-ff', '-m', 'Merge pull request #99 from contributor/nested-feature', 'nested-feature');
+ git('switch', '--quiet', 'main');
+ git('merge', '--quiet', '--no-ff', '-m', 'Merge pull request #100 from contributor/feature', 'feature');
+ git('commit', '--allow-empty', '--quiet', '-m', 'chore: direct change (#101)');
+ git('switch', '--quiet', '-c', 'nested');
+ git('commit', '--allow-empty', '--quiet', '-m', 'feat: nested change (#102)');
+ git('switch', '--quiet', 'main');
+ git('merge', '--quiet', '--no-ff', '-m', 'Merge branch nested', 'nested');
+ git('tag', 'end');
+
+ const previousCwd = process.cwd();
+ process.chdir(repo);
+ t.after(() => process.chdir(previousCwd));
+
+ const commits = await collectCommits('start', 'end');
+ assert.deepEqual(commits.map((commit) => commit.primaryPrNumber), [100]);
});
test('OpenAI request contains required release sections and compare payload', () => {
@@ -240,7 +278,7 @@ test('record splitter reassembles records across chunk boundaries', () => {
assert.deepEqual(records, ['alpha', 'beta', 'gamma']);
});
-test('commit collection survives a git log larger than the 1 MiB spawn buffer', async (t) => {
+test('merge collection survives a git log larger than the 1 MiB spawn buffer', async (t) => {
// Regression guard for the v0.63.21 release failure: `execFileSync` buffers the
// child's whole stdout and throws `spawnSync git ENOBUFS` past Node's 1 MiB
// `maxBuffer` default. The release span grows with every unpublished tag, so the
@@ -270,13 +308,12 @@ test('commit collection survives a git log larger than the 1 MiB spawn buffer',
const COMMITS = 150;
const SUBJECT_PADDING = 8000;
for (let index = 0; index < COMMITS; index += 1) {
- git(
- 'commit',
- '--allow-empty',
- '--quiet',
- '-m',
- `chore: padded commit ${index} ${'x'.repeat(SUBJECT_PADDING)} (#${1000 + index})`,
- );
+ git('switch', '--quiet', '-c', `feature-${index}`);
+ git('commit', '--allow-empty', '--quiet', '-m', `feature ${index}`);
+ git('switch', '--quiet', 'main');
+ git('merge', '--quiet', '--no-ff', '-m',
+ `Merge pull request #${1000 + index} from contributor/feature-${index} ${'x'.repeat(SUBJECT_PADDING)}`,
+ `feature-${index}`);
}
git('tag', 'end');
@@ -289,7 +326,7 @@ test('commit collection survives a git log larger than the 1 MiB spawn buffer',
const rawBytes = Buffer.byteLength(
execFileSync(
'git',
- ['log', 'start..end', '--reverse', '--format=%H%x1f%s%x1f%an%x1f%ae%x1f%aI%x1e'],
+ ['log', 'start..end', '--first-parent', '--merges', '--reverse', '--format=%H%x1f%s%x1f%an%x1f%ae%x1f%aI%x1e'],
{
cwd: repo,
encoding: 'utf8',
diff --git a/scripts/release/generate-release-notes.mjs b/scripts/release/generate-release-notes.mjs
index 8f3f59222b..62e57cb3df 100644
--- a/scripts/release/generate-release-notes.mjs
+++ b/scripts/release/generate-release-notes.mjs
@@ -237,7 +237,11 @@ function assertRefExists(ref, label) {
}
export function extractPullRequestNumbers(subject) {
- const matches = [...String(subject || '').matchAll(/\(#(\d+)\)/g)];
+ const text = String(subject || '');
+ const matches = [
+ ...text.matchAll(/\(#(\d+)\)/g),
+ ...text.matchAll(/^Merge pull request #(\d+)\b/g),
+ ];
return [...new Set(matches.map((match) => Number(match[1])).filter(Number.isInteger))];
}
@@ -271,10 +275,13 @@ export function parseGitLog(logText) {
export async function collectCommits(from, to) {
const format = '%H%x1f%s%x1f%an%x1f%ae%x1f%aI%x1e';
const commits = [];
- await streamGitRecords(['log', `${from}..${to}`, '--reverse', `--format=${format}`], (entry) => {
+ await streamGitRecords(['log', `${from}..${to}`, '--first-parent', '--merges', '--reverse', `--format=${format}`], (entry) => {
const trimmed = entry.trim();
if (trimmed) {
- commits.push(parseCommitRecord(trimmed));
+ const commit = parseCommitRecord(trimmed);
+ if (commit.primaryPrNumber) {
+ commits.push(commit);
+ }
}
});
return commits;