mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Migrate unreleased changes in changelog (#10853)
When updating the changelog for a release candidate, any unreleased changes are now migrated to the release header. Generally we don't make a habit of adding changes to the changelog prior to creating a release candidate, but if any are there we certainly don't want them duplicated.
This commit is contained in:
parent
a814f8ee75
commit
e77aa0b7b5
@ -233,6 +233,36 @@ class Changelog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate all unreleased changes to a release section.
|
||||
*
|
||||
* Changes are migrated in their existing categories, and placed above any
|
||||
* pre-existing changes in that category.
|
||||
*
|
||||
* @param {Version} version - The release version to migrate unreleased
|
||||
* changes to.
|
||||
*/
|
||||
migrateUnreleasedChangesToRelease(version) {
|
||||
const releaseChanges = this._changes[version];
|
||||
if (!releaseChanges) {
|
||||
throw new Error(`Specified release version does not exist: '${version}'`);
|
||||
}
|
||||
|
||||
const unreleasedChanges = this._changes[unreleased];
|
||||
|
||||
for (const category of Object.keys(unreleasedChanges)) {
|
||||
if (releaseChanges[category]) {
|
||||
releaseChanges[category] = [
|
||||
...unreleasedChanges[category],
|
||||
...releaseChanges[category],
|
||||
];
|
||||
} else {
|
||||
releaseChanges[category] = unreleasedChanges[category];
|
||||
}
|
||||
}
|
||||
this._changes[unreleased] = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata for all releases.
|
||||
* @returns {Array<ReleaseMetadata>} The metadata for each release.
|
||||
|
@ -127,7 +127,11 @@ async function updateChangelog({
|
||||
({ prNumber }) => !loggedPrNumbers.includes(prNumber),
|
||||
);
|
||||
|
||||
if (newCommits.length === 0) {
|
||||
const hasUnreleasedChanges = changelog.getUnreleasedChanges().length !== 0;
|
||||
if (
|
||||
newCommits.length === 0 &&
|
||||
(!isReleaseCandidate || hasUnreleasedChanges)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -141,6 +145,10 @@ async function updateChangelog({
|
||||
changelog.addRelease({ currentVersion });
|
||||
}
|
||||
|
||||
if (isReleaseCandidate && hasUnreleasedChanges) {
|
||||
changelog.migrateUnreleasedChangesToRelease(currentVersion);
|
||||
}
|
||||
|
||||
const newChangeEntries = newCommits.map(({ prNumber, description }) => {
|
||||
if (prNumber) {
|
||||
const prefix = `[#${prNumber}](${repoUrl}/pull/${prNumber})`;
|
||||
|
Loading…
Reference in New Issue
Block a user