Skip to content

chore(script): improve markdown changelog output in sync-react.js #52052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions scripts/sync-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Or, run this command with no arguments to use the most recently published versio
`GitHub reported no changes between ${baseSha} and ${newSha}.`
)
} else {
console.log('Includes the following upstream changes:\n\n' + changelog)
console.log(`### React upstream changes\n\n${changelog}\n\n`)
}
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -191,11 +191,19 @@ async function getChangelogFromGitHub(baseSha, newSha) {

const { commits } = data
for (const { commit, sha } of commits) {
changelog.push(
`- ${sha.slice(0, 9)} ${commit.message.split('\n')[0]} (${
commit.author.name
})`
)
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 prNum = match ? match[1] : ''
if (prNum) {
changelog.push(`- https://github.com/facebook/react/pulls/${prNum}`)
} else {
changelog.push(
`- ${sha.slice(0, 9)} ${commit.message.split('\n')[0]} (${
commit.author.name
})`
)
}
}

if (commits.length !== pageSize) {
Expand Down