Skip to content
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

Fix sync-react changelog #66532

Merged
merged 2 commits into from
Jun 5, 2024
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
24 changes: 13 additions & 11 deletions scripts/sync-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ Or, run this command with no arguments to use the most recently published versio
console.log()
}

console.log(`Successfully updated React from ${baseSha} to ${newSha}.\n`)

// Fetch the changelog from GitHub and print it to the console.
try {
const changelog = await getChangelogFromGitHub(baseSha, newSha)
Expand Down Expand Up @@ -178,6 +176,13 @@ Or run this command again without the --no-install flag to do both automatically
`
)
}

console.log(
`Successfully updated React from ${baseSha} to ${newSha}.\n` +
`Don't forget to find & replace all references to the React version '${baseVersionStr}' with '${newVersionStr}':\n` +
`-${baseVersionStr}\n` +
`+${newVersionStr}\n`
)
}

function readBoolArg(argv, argName) {
Expand All @@ -189,8 +194,8 @@ function readStringArg(argv, argName) {
return argIndex === -1 ? null : argv[argIndex + 1]
}

function extractInfoFromReactVersion(reactCanaryVersion) {
const match = reactCanaryVersion.match(
function extractInfoFromReactVersion(reactVersion) {
const match = reactVersion.match(
/(?<semverVersion>.*)-(?<releaseLabel>.*)-(?<sha>.*)-(?<dateString>.*)$/
)
return match ? match.groups : null
Expand All @@ -199,7 +204,7 @@ function extractInfoFromReactVersion(reactCanaryVersion) {
async function getChangelogFromGitHub(baseSha, newSha) {
const pageSize = 50
let changelog = []
for (let currentPage = 0; ; currentPage++) {
for (let currentPage = 1; ; currentPage++) {
const url = `https://api.github.com/repos/facebook/react/compare/${baseSha}...${newSha}?per_page=${pageSize}&page=${currentPage}`
const headers = {}
// GITHUB_TOKEN is optional but helps in case of rate limiting during development.
Expand All @@ -216,10 +221,7 @@ async function getChangelogFromGitHub(baseSha, newSha) {
}
const data = await response.json()

const { base_commit, commits } = data
if (currentPage === 0) {
commits.unshift(base_commit)
}
const { commits } = data
for (const { commit, sha } of commits) {
const title = commit.message.split('\n')[0] || ''
const match =
Expand Down Expand Up @@ -251,8 +253,8 @@ async function getChangelogFromGitHub(baseSha, newSha) {
return changelog.length > 0 ? changelog.join('\n') : null
}

sync('rc')
.then(() => sync('experimental'))
sync('experimental')
.then(() => sync('rc'))
.catch((error) => {
console.error(error)
process.exit(1)
Expand Down
Loading