Skip to content

Commit 7f1286b

Browse files
committed
fix prefixes being omitted (#60)
Closes #59 Reviewed-on: https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/60 Co-authored-by: Justin Elmore <[email protected]> Co-committed-by: Justin Elmore <[email protected]>
1 parent 86d94fb commit 7f1286b

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

LICENSE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ MIT License
22

33
Copyright (c) 2025 Justin Elmore
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6-
associated documentation files (the "Software"), to deal in the Software without restriction, including
7-
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6+
associated documentation files (the "Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
99
following conditions:
1010

11-
The above copyright notice and this permission notice shall be included in all copies or substantial
11+
The above copyright notice and this permission notice shall be included in all copies or substantial
1212
portions of the Software.
1313

14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15-
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16-
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18-
USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18+
USE OR OTHER DEALINGS IN THE SOFTWARE.

changelog/fix.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 1.3.1
2+
release_date: 2025-01-01
3+
author: "[Justin Elmore](https://git.justinelmore.dev/jelmore1674)"
4+
5+
fixed:
6+
bug:
7+
- Prevent changes with a prefix from being omitted when parsing from existing changelog.
8+
9+
references:
10+
- type: pull_request
11+
reference: 60
12+
- type: issue
13+
reference: 59

generate/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/parseChangelog.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,17 @@ Here we would have the update steps for 1.2.4 for people to follow.
191191
added: ["[Breaking 🧨] - this cool change"],
192192
}]);
193193
});
194+
195+
test("can return multiple prefixes", () => {
196+
vi.spyOn(fs, "existsSync").mockReturnValue(true);
197+
vi.spyOn(fs, "readFileSync").mockReturnValueOnce(
198+
`# Changelog\n\n## [1.0.0] - 2024-12-07\n\n### Added\n\n- [Breaking 🧨] - this cool change.\n- [Breaking 🧨] - this other change here.\n\n[1.0.0]: https://test.com`,
199+
);
200+
const cl = parseChangelog("CHANGELOG.md");
201+
expect(cl).toEqual([{
202+
version: "1.0.0",
203+
release_date: "2024-12-07",
204+
added: ["[Breaking 🧨] - this cool change.", "[Breaking 🧨] - this other change here."],
205+
}]);
206+
});
194207
});

src/lib/parseChangelog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function parseChangelog(changelogPath: string) {
5858
"",
5959
).trim().split("\n- ")
6060
.map((change: string) =>
61-
change.replace(/^\[.*/gism, "")
61+
change.replace(/^\[(\d\.\d\.\d|unreleased).*/gism, "")
6262
.replace(/^- /g, "")
6363
.replace(/\n /g, "")
6464
.trim()

0 commit comments

Comments
 (0)