Skip to content

Commit 9c2037e

Browse files
authored
v0.7.1 (#18)
1 parent 0282748 commit 9c2037e

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
This project follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
33

4+
## [0.7.1] - 2023-06-11
5+
### Added
6+
- The `printChanges() function to print changes only and skip the header part
7+
48
## [0.7.0] - 2023-06-11
59
### Added
610
- Keep freetext directly under release headings
@@ -118,6 +122,7 @@ This project follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.
118122
- Parsing from markdown
119123
- Writing to markdown
120124

125+
[0.7.1]: https://github.com/f3ath/change/compare/0.7.0...0.7.1
121126
[0.7.0]: https://github.com/f3ath/change/compare/0.6.0...0.7.0
122127
[0.6.0]: https://github.com/f3ath/change/compare/0.5.0...0.6.0
123128
[0.5.0]: https://github.com/f3ath/change/compare/0.4.0...0.5.0

lib/src/printer.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ String printUnreleased(Section unreleased) => render(
2525
flavor: flavors.changelog,
2626
);
2727

28+
/// Converts the Unreleased/Release [section] to a markdown string.
29+
/// This is the same as [printRelease] and [printUnreleased] but skips
30+
/// the header line and the bottom (non-inline) links section.
31+
String printChanges(Section section) => render(
32+
_changes(section),
33+
flavor: flavors.changelog,
34+
);
35+
2836
final _iso8601 = DateFormat('yyyy-MM-dd').format;
2937

3038
Iterable<Node> _changelog(Changelog log,
@@ -46,7 +54,6 @@ Iterable<Element> _unreleased(Section section) sync* {
4654
header.add(_link(sectionLink, [text]));
4755
}
4856
yield Element('h2', header);
49-
yield* section.preamble;
5057
yield* _changes(section);
5158
}
5259

@@ -64,11 +71,11 @@ Iterable<Element> _release(Release release) sync* {
6471
header.add(Text(' [YANKED]'));
6572
}
6673
yield Element('h2', header);
67-
yield* release.preamble;
6874
yield* _changes(release);
6975
}
7076

7177
Iterable<Element> _changes(Section section) sync* {
78+
yield* section.preamble;
7279
final types = Set.of(section.changes().map((e) => e.type)).toList();
7380
types.sort();
7481
for (final type in types) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: change
2-
version: 0.7.0
2+
version: 0.7.1
33
description: A Changelog manipulation library. Read/modify/write your CHANGELOG.md. Inspired by keepachangelog.com.
44
homepage: "https://github.com/f3ath/change"
55

test/changelog_test.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,44 @@ void main() {
154154
'[0.0.1]: https://example.com',
155155
].join('\n'));
156156
});
157+
158+
test('Can print changes from a release', () {
159+
final release =
160+
Release(Version.parse('0.0.1'), DateTime.parse('2020-02-02'));
161+
release.add(Change('Added', [Text('Some change')]));
162+
release.add(Change('Fixed', [Text('A nasty bug')]));
163+
release.preamble.add(Element('p', [Text('This is the preamble.')]));
164+
release.link = 'https://example.com';
165+
expect(
166+
printChanges(release),
167+
[
168+
'This is the preamble.',
169+
'',
170+
'### Added',
171+
'- Some change',
172+
'',
173+
'### Fixed',
174+
'- A nasty bug',
175+
].join('\n'));
176+
});
177+
178+
test('Can print unreleased changes', () {
179+
final unreleased = Section();
180+
unreleased.add(Change('Added', [Text('Some change')]));
181+
unreleased.add(Change('Fixed', [Text('A nasty bug')]));
182+
unreleased.preamble.add(Element('p', [Text('This is the preamble.')]));
183+
expect(
184+
printChanges(unreleased),
185+
[
186+
'This is the preamble.',
187+
'',
188+
'### Added',
189+
'- Some change',
190+
'',
191+
'### Fixed',
192+
'- A nasty bug',
193+
].join('\n'));
194+
});
157195
});
158196

159197
group('Non-standard', () {

0 commit comments

Comments
 (0)