Skip to content
Draft
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
27 changes: 26 additions & 1 deletion .github/scripts/generate-rc-commits.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ async function filterCommitsByTeam(platform, branchA, branchB) {
try {
const git = simpleGit();

// Fetch all branches and tags to ensure references exist
await git.fetch(['--all', '--tags', '--prune']);

// Check if branchA exists
let branchAExists = true;
try {
await git.revparse([branchA]);
} catch (e) {
branchAExists = false;
}

// Check if branchB exists
let branchBExists = true;
try {
await git.revparse([branchB]);
} catch (e) {
branchBExists = false;
}

if (!branchAExists || !branchBExists) {
throw new Error(
`Cannot find reference(s):${!branchAExists ? ` ${branchA}` : ''}${!branchBExists ? ` ${branchB}` : ''}.`
);
}

const logOptions = {
from: branchB,
to: branchA,
Expand Down Expand Up @@ -223,7 +248,7 @@ async function main() {
`Generating CSV file for commits between ${branchA} and ${branchB} on ${platform} platform...`,
);

const commitsByTeam = await filterCommitsByTeam(platform, branchA, branchB);
const commitsByTeam = await filterCommitsByTeam(platform, `origin/${branchA}`, `origin/${branchB}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Branch Validation Mismatch

The branch existence validation checks for local branches (branchA, branchB), but the filterCommitsByTeam function subsequently uses remote branches (origin/${branchA}, origin/${branchB}). This inconsistency means the script might pass validation when local branches exist but fail during the git log operation if the corresponding remote branches are missing, or vice versa. The validation should check the same remote references that are used.

Fix in Cursor Fix in Web


if (Object.keys(commitsByTeam).length === 0) {
console.log('No commits found.');
Expand Down
Loading