Skip to content

Commit

Permalink
[core] Use PR labels to identify the package a l10n PR belongs to (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Apr 3, 2024
1 parent 83fd4ef commit d6e6c75
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions scripts/releaseChangelog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ async function findLatestTaggedVersion(octokit) {
return data[0].name.trim();
}

function resolvePackageByLabels(labels) {
let resolvedPackage = null;
labels.forEach((label) => {
switch (label.name) {
case 'component: data grid':
resolvedPackage = 'DataGrid';
break;
case 'component: pickers':
resolvedPackage = 'pickers';
break;
default:
break;
}
});
return resolvedPackage;
}

async function main(argv) {
const { githubToken, lastRelease: lastReleaseInput, release } = argv;

Expand Down Expand Up @@ -89,6 +106,7 @@ async function main(argv) {
// Fetch all the pull Request and check if there is a section named changelog

const changeLogMessages = [];
const prsLabelsMap = {};
await Promise.all(
commitsItems.map(async (commitsItem) => {
const searchPullRequestId = commitsItem.commit.message.match(/\(#([0-9]+)\)/);
Expand All @@ -97,13 +115,15 @@ async function main(argv) {
}

const {
data: { body: bodyMessage },
data: { body: bodyMessage, labels },
} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
owner: GIT_ORGANIZATION,
repo: GIT_REPO,
pull_number: Number(searchPullRequestId[1]),
});

prsLabelsMap[commitsItem.sha] = labels;

if (!bodyMessage) {
return;
}
Expand Down Expand Up @@ -146,8 +166,6 @@ async function main(argv) {
const tag = parseTags(commitItem.commit.message);
switch (tag) {
case 'DataGrid':
case 'l10n':
case '118n':
dataGridCommits.push(commitItem);
break;
case 'DataGridPro':
Expand Down Expand Up @@ -182,6 +200,25 @@ async function main(argv) {
case 'codemod':
codemodCommits.push(commitItem);
break;
case 'l10n':
case '118n': {
const prLabels = prsLabelsMap[commitItem.sha];
const resolvedPackage = resolvePackageByLabels(prLabels);
if (resolvedPackage) {
switch (resolvedPackage) {
case 'DataGrid':
dataGridCommits.push(commitItem);
break;
case 'pickers':
pickersCommits.push(commitItem);
break;
default:
coreCommits.push(commitItem);
break;
}
}
break;
}
default:
otherCommits.push(commitItem);
break;
Expand Down

0 comments on commit d6e6c75

Please sign in to comment.