From 87d026e57681aa2709c5652a47342779f9ee2edb Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 22 May 2024 10:43:13 +0200 Subject: [PATCH 1/2] Linkify React commits in sync changelog Example: `[[compiler:playground] Update babel.config.js facebook/react@0f5845480](https://github.com/facebook/react/commit/0f584548038335d3aa36d2dbc379cde664158eb3) (Lauren Tan)`` `facebook/react@commit` would be sufficient for GitHub but doesn't preview the title like PR linking does. --- scripts/sync-react.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/sync-react.js b/scripts/sync-react.js index d7663ebf1cf61..30767e9595f42 100644 --- a/scripts/sync-react.js +++ b/scripts/sync-react.js @@ -218,9 +218,7 @@ async function getChangelogFromGitHub(baseSha, newSha) { changelog.push(`- https://github.com/facebook/react/pull/${prNum}`) } else { changelog.push( - `- ${sha.slice(0, 9)} ${commit.message.split('\n')[0]} (${ - commit.author.name - })` + `- [${commit.message.split('\n')[0]} facebook/react@${sha.slice(0, 9)}](https://github.com/facebook/react/commit/${sha}) (${commit.author.name})` ) } } From cad04a47ce76cfa46dd22cfa02ce81c3c9993117 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 22 May 2024 10:50:22 +0200 Subject: [PATCH 2/2] Handle PRs landed via ghstack --- scripts/sync-react.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/sync-react.js b/scripts/sync-react.js index 30767e9595f42..edad0dd11fccd 100644 --- a/scripts/sync-react.js +++ b/scripts/sync-react.js @@ -211,8 +211,13 @@ async function getChangelogFromGitHub(baseSha, newSha) { } for (const { commit, sha } of commits) { const title = commit.message.split('\n')[0] || '' - // The "title" looks like "[Fiber][Float] preinitialized stylesheets should support integrity option (#26881)" - const match = /\(#([0-9]+)\)$/.exec(title) + const match = + // The "title" looks like "[Fiber][Float] preinitialized stylesheets should support integrity option (#26881)" + /\(#([0-9]+)\)$/.exec(title) ?? + // or contains "Pull Request resolved: https://github.com/facebook/react/pull/12345" in the body if merged via ghstack (e.g. https://github.com/facebook/react/commit/0a0a5c02f138b37e93d5d93341b494d0f5d52373) + /^Pull Request resolved: https:\/\/github.com\/facebook\/react\/pull\/([0-9]+)$/m.exec( + commit.message + ) const prNum = match ? match[1] : '' if (prNum) { changelog.push(`- https://github.com/facebook/react/pull/${prNum}`)