1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Add categories to each changelog release (#10837)

Each changelog release now has category headers. The standard "keep a
changelog" [1] categories are used, along with the addition of
"Uncategorized" for any changes that have not yet been categorized.

The changelog script has been updated to add this "Uncategorized"
header if it isn't already present, and to place any new commits under
this header.

The changelog has been updated to property categorize each change in
recent releases, and to place changes in older releases under the
header "Uncategorized".

[1]: https://keepachangelog.com/en/1.0.0/
This commit is contained in:
Mark Stacey 2021-04-07 13:12:07 -02:30 committed by GitHub
parent 284c2cb481
commit 1c5dcd6efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 329 additions and 295 deletions

File diff suppressed because it is too large Load Diff

View File

@ -69,6 +69,37 @@ async function main() {
const changelog = await fs.readFile(changelogFilename, { encoding: 'utf8' });
const changelogLines = changelog.split('\n');
const prNumbersWithChangelogEntries = [];
for (const line of changelogLines) {
const matchResults = line.match(/- \[#(\d+)\]/u);
if (matchResults === null) {
continue;
}
const prNumber = matchResults[1];
prNumbersWithChangelogEntries.push(prNumber);
}
const changelogEntries = [];
for (const { prNumber, description } of commitEntries) {
if (prNumbersWithChangelogEntries.includes(prNumber)) {
continue;
}
let changelogEntry;
if (prNumber) {
const prefix = `[#${prNumber}](${URL}/pull/${prNumber})`;
changelogEntry = `- ${prefix}: ${description}`;
} else {
changelogEntry = `- ${description}`;
}
changelogEntries.push(changelogEntry);
}
if (changelogEntries.length === 0) {
console.log('CHANGELOG required no updates');
return;
}
// remove the "v" prefix
const mostRecentVersion = mostRecentTag.slice(1);
@ -117,33 +148,21 @@ async function main() {
);
}
const prNumbersWithChangelogEntries = [];
for (const line of changelogLines) {
const matchResults = line.match(/- \[#(\d+)\]/u);
if (matchResults === null) {
continue;
}
const prNumber = matchResults[1];
prNumbersWithChangelogEntries.push(prNumber);
// Ensure "Uncategorized" header is present
const uncategorizedHeaderIndex = releaseHeaderIndex + 1;
const uncategorizedHeader = '### Uncategorized';
if (changelogLines[uncategorizedHeaderIndex] !== '### Uncategorized') {
const hasEmptyLine = changelogLines[uncategorizedHeaderIndex] === '';
changelogLines.splice(
uncategorizedHeaderIndex,
0,
uncategorizedHeader,
// Ensure an empty line follows the new header
...(hasEmptyLine ? [] : ['']),
);
}
const changelogEntries = [];
for (const { prNumber, description } of commitEntries) {
if (prNumbersWithChangelogEntries.includes(prNumber)) {
continue;
}
let changelogEntry;
if (prNumber) {
const prefix = `[#${prNumber}](${URL}/pull/${prNumber})`;
changelogEntry = `- ${prefix}: ${description}`;
} else {
changelogEntry = `- ${description}`;
}
changelogEntries.push(changelogEntry);
}
changelogLines.splice(releaseHeaderIndex + 1, 0, ...changelogEntries);
changelogLines.splice(uncategorizedHeaderIndex + 1, 0, ...changelogEntries);
const updatedChangelog = changelogLines.join('\n');
await fs.writeFile(changelogFilename, updatedChangelog);