Add release header when updating changelog (#10794)

The changelog update script now adds a release header if it doesn't
find one already that matches the current release candidate version.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent b2f6aa9f65
commit 5b5a4f6fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      development/auto-changelog.js

@ -80,17 +80,24 @@ async function main() {
`${versionHeader}$|${versionHeader}\\s`
: currentDevelopBranchHeader;
const releaseHeaderIndex = changelogLines.findIndex((line) =>
let releaseHeaderIndex = changelogLines.findIndex((line) =>
line.match(new RegExp(currentReleaseHeaderPattern, 'u')),
);
if (releaseHeaderIndex === -1) {
if (!isReleaseCandidate) {
throw new Error(
`Failed to find release header '${
isReleaseCandidate ? versionHeader : currentDevelopBranchHeader
}'`,
`Failed to find release header '${currentDevelopBranchHeader}'`,
);
}
// Add release header if not found
const firstReleaseHeaderIndex = changelogLines.findIndex((line) =>
line.match(/## \d+\.\d+\.\d+/u),
);
changelogLines.splice(firstReleaseHeaderIndex, 0, versionHeader, '');
releaseHeaderIndex = firstReleaseHeaderIndex;
}
const prNumbersWithChangelogEntries = [];
for (const line of changelogLines) {
const matchResults = line.match(/- \[#(\d+)\]/u);

Loading…
Cancel
Save