The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(release): credit PR authors in merge-only notes
Steven Enamakel1bb9117b8e8f
diff --git a/scripts/__tests__/generate-release-notes.test.mjs b/scripts/__tests__/generate-release-notes.test.mjsindex 1e5e331d0a..f390c4043c 100644--- a/scripts/__tests__/generate-release-notes.test.mjs+++ b/scripts/__tests__/generate-release-notes.test.mjs@@ -9,13 +9,13 @@ import {buildOpenAiRequest,buildReleasePayload,collectCommits,+ collectContributorStats,createRecordSplitter,ensureAllPullRequestsLinked,extractPullRequestNumbers,parseArgs,parseGitHubRepoFromRemote,parseGitLog,- priorAuthorKeys,renderDeterministicNotes,} from '../release/generate-release-notes.mjs';@@ -84,6 +84,19 @@ test('release notes collect only first-parent pull request merges', async (t) =>assert.deepEqual(commits.map((commit) => commit.primaryPrNumber), [100]);});+test('contributor credits use PR authors instead of merge authors', () => {+ const contributors = collectContributorStats([+ { number: 100, author: 'new-contributor', authorAssociation: 'FIRST_TIME_CONTRIBUTOR' },+ { number: 101, author: 'returning-contributor', authorAssociation: 'CONTRIBUTOR' },+ { number: 102, author: 'new-contributor', authorAssociation: 'CONTRIBUTOR' },+ ]);++ assert.deepEqual(contributors, [+ { name: 'new-contributor', commits: 2, prs: [100, 102], isNew: true },+ { name: 'returning-contributor', commits: 1, prs: [101], isNew: false },+ ]);+});+test('OpenAI request contains required release sections and compare payload', () => {const payload = buildReleasePayload({from: 'v1.0.0',@@ -346,6 +359,4 @@ test('merge collection survives a git log larger than the 1 MiB spawn buffer', aassert.equal(commits.at(-1).primaryPrNumber, 1000 + COMMITS - 1);assert.ok(commits.every((commit) => commit.sha.length === 40));- const priorKeys = await priorAuthorKeys('start');- assert.ok(priorKeys.has('range fixture <[email protected]>'));});diff --git a/scripts/release/generate-release-notes.mjs b/scripts/release/generate-release-notes.mjsindex 62e57cb3df..3b9d35c10b 100644--- a/scripts/release/generate-release-notes.mjs+++ b/scripts/release/generate-release-notes.mjs@@ -287,39 +287,25 @@ export async function collectCommits(from, to) {return commits;}-export async function priorAuthorKeys(from) {- const keys = new Set();- await streamGitRecords(['log', from, '--format=%an%x1f%ae%x1e'], (entry) => {- const [name, email] = entry.trim().split('\x1f');- if (name || email) {- keys.add(authorKey({ authorName: name, authorEmail: email }));- }- });- return keys;-}--function authorKey(author) {- return `${String(author.authorName || '').toLowerCase()} <${String(author.authorEmail || '').toLowerCase()}>`;-}--function collectContributorStats(commits, priorKeys) {+export function collectContributorStats(pullRequests) {const contributors = new Map();- for (const commit of commits) {- const key = authorKey(commit);+ for (const pullRequest of pullRequests) {+ if (!pullRequest.author) {+ continue;+ }+ const key = pullRequest.author.toLowerCase();if (!contributors.has(key)) {contributors.set(key, {- name: commit.authorName,- email: commit.authorEmail,+ name: pullRequest.author,commits: 0,prs: new Set(),- isNew: !priorKeys.has(key),+ isNew: false,});}const contributor = contributors.get(key);contributor.commits += 1;- if (commit.primaryPrNumber) {- contributor.prs.add(commit.primaryPrNumber);- }+ contributor.prs.add(pullRequest.number);+ contributor.isNew ||= ['FIRST_TIMER', 'FIRST_TIME_CONTRIBUTOR'].includes(pullRequest.authorAssociation);}return [...contributors.values()]@@ -347,19 +333,31 @@ function collectPrCommits(commits) {function fetchPullRequest(repo, number) {try {+ const [owner, name] = repo.split('/');+ const query = `query($owner: String!, $name: String!, $number: Int!) {+ repository(owner: $owner, name: $name) {+ pullRequest(number: $number) {+ number title url mergedAt body authorAssociation+ author { login }+ labels(first: 100) { nodes { name } }+ }+ }+ }`;const json = runGh([- 'pr',- 'view',- String(number),- '--repo',- repo,- '--json',- 'number,title,url,author,mergedAt,body,labels',+ 'api', 'graphql',+ '-f', `query=${query}`,+ '-f', `owner=${owner}`,+ '-f', `name=${name}`,+ '-F', `number=${number}`,],{ allowFailure: true },);- return JSON.parse(json);+ const detail = JSON.parse(json)?.data?.repository?.pullRequest;+ if (!detail) {+ throw new Error('GitHub returned no pull request');+ }+ return { ...detail, labels: detail.labels?.nodes || [] };} catch (error) {const message = error instanceof Error ? error.message : String(error);return {@@ -370,6 +368,7 @@ function fetchPullRequest(repo, number) {mergedAt: null,body: null,labels: [],+ authorAssociation: null,warning: `Failed to fetch PR metadata with gh: ${message}`,};}@@ -388,6 +387,7 @@ function collectPullRequests(repo, commits) {title: detail.title || fallbackTitle,url: detail.url || `https://github.com/${repo}/pull/${number}`,author: detail.author?.login || commitsForPr.at(-1)?.authorName || null,+ authorAssociation: detail.authorAssociation || null,mergedAt: detail.mergedAt || commitsForPr.at(-1)?.authoredAt || null,labels: (detail.labels || []).map((label) => label.name || label).filter(Boolean),body: trimBody(detail.body),@@ -760,8 +760,8 @@ async function main() {console.error(`[release-notes] Collecting ${repo} changes from ${from} to ${resolvedTo}`);const commits = await collectCommits(from, resolvedTo);- const contributors = collectContributorStats(commits, await priorAuthorKeys(from));const pullRequests = collectPullRequests(repo, commits);+ const contributors = collectContributorStats(pullRequests);const payload = buildReleasePayload({from,to: options.to,