forked from nullxception/boorusphere
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
260e6fc
commit 4365137
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,6 @@ lib/**/*.gr.dart | |
# test stuff | ||
coverage/lcov.info | ||
test/full_coverage_test.dart | ||
|
||
# Releases | ||
releasenote.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as path; | ||
|
||
typedef Changelog = MapEntry<String, List<String>>; | ||
|
||
List<Changelog> parseChangelog(String string) { | ||
final data = <Changelog>[]; | ||
|
||
final lines = const LineSplitter() | ||
.convert(string) | ||
.map((it) => it.trim()) | ||
.where((it) => it.isNotEmpty); | ||
|
||
for (final line in lines) { | ||
if (line.startsWith('## ')) { | ||
final ver = line.replaceFirst('## ', '').trim(); | ||
data.add(Changelog(ver, [])); | ||
} else if (line.startsWith('* ')) { | ||
final log = line.replaceFirst('* ', '').trim(); | ||
data.last = Changelog(data.last.key, [...data.last.value, log]); | ||
} else if (line.isNotEmpty && data.last.value.isNotEmpty) { | ||
final newlinelog = '${data.last.value.last}\n$line'; | ||
final lastlog = data.last.value.sublist(0, data.last.value.length - 1); | ||
data.last = Changelog(data.last.key, [...lastlog, newlinelog]); | ||
} | ||
} | ||
return data; | ||
} | ||
|
||
void main() async { | ||
final text = StringBuffer(); | ||
|
||
final notes = File(path.join(Directory.current.path, 'releasenote.md')); | ||
final changelog = File(path.join(Directory.current.path, 'CHANGELOG.md')); | ||
|
||
final data = parseChangelog(changelog.readAsStringSync()); | ||
final Changelog(key: version, value: logs) = data.first; | ||
|
||
text.writeln("# What's new in $version"); | ||
text.writeln(); | ||
for (final log in logs) { | ||
text.writeln('- $log'); | ||
} | ||
|
||
notes.writeAsStringSync(text.toString()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters