Skip to content

Commit

Permalink
fix changelog updating
Browse files Browse the repository at this point in the history
  • Loading branch information
anbraten committed Jul 23, 2023
1 parent 60946df commit e424b5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/utils/change.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const changes: Change[] = [
];
const config: Config = {
ci: {
branch: "main",
releaseBranch: "main",
commitMessage: "chore(release): 1.0.0 [skip ci]",
configFile: "ready-go-release.config.ts",
eventType: "push",
Expand Down Expand Up @@ -94,6 +94,7 @@ describe("change", () => {
changes
.filter((change) => !change.labels.includes("breaking"))
.filter((change) => !change.labels.includes("feature"))
.filter((change) => !change.labels.includes("enhancement"))
);

expect(nextVersion).toBe("1.0.1");
Expand Down Expand Up @@ -133,7 +134,7 @@ describe("change", () => {
### ✨ Features
- Add new feature (#1338) @Alice Wonderland
`;
`;
const forge = new GithubForge("", "");
const nextVersion = "1.0.0";
const newSection = getChangeLogSection(
Expand Down
6 changes: 4 additions & 2 deletions src/utils/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ export function updateChangelogSection(
const sectionBegin = `## [`;
while (oldChangelog.includes(sectionBegin)) {
const start = oldChangelog.indexOf(sectionBegin);
const end =
oldChangelog.indexOf(sectionBegin, start + 1) || oldChangelog.length;
let end = oldChangelog.indexOf(sectionBegin, start + 1);
if (end === -1) {
end = oldChangelog.length + 1;
}

const section = oldChangelog.slice(start, end).trim();
const version = section.match(/\[(.*?)\]/)?.[1];
Expand Down

0 comments on commit e424b5d

Please sign in to comment.