Skip to content

Commit d63b2a4

Browse files
committed
Assume '[UNRELEASED]' section is first section
1 parent b246e56 commit d63b2a4

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

‎pr-checks/changelog.ts‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,9 @@ export function addBodyLinesToUnreleasedSection(
146146
changelog: Changelog,
147147
lines: string[],
148148
) {
149-
// Find the '[UNRELEASED]' section.
150-
let unreleasedSection: ChangelogSection | undefined;
151-
for (const section of changelog.sections) {
152-
if (getHeader(section.headerLine) === UNRELEASED_PLACEHOLDER) {
153-
unreleasedSection = section;
154-
break;
155-
}
156-
}
157-
158-
// Ensure that the '[UNRELEASED]' section exists first.
159-
if (unreleasedSection === undefined) {
160-
throw Error(
161-
"Cannot put changenotes into CHANGELOG.md's '[UNRELEASED]' section because it does not exist",
162-
);
149+
const unreleasedSection = changelog.sections[0];
150+
if (getHeader(unreleasedSection.headerLine) !== UNRELEASED_PLACEHOLDER) {
151+
throw Error("'[UNRELEASED]' is not the first section of 'CHANGELOG.md'");
163152
}
164153

165154
let insertAtIndex = 0;

0 commit comments

Comments
 (0)