Skip to content

Commit 74e4df1

Browse files
authored
Sort categories from: new features, bugfixes and removed (#4)
* cz * sort categories from new features, bugfixes and removed
1 parent 1a0d956 commit 74e4df1

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License
22
---------------
33

4-
Copyright (c) 2017-present Tomáš Votruba (https://tomasvotruba.cz)
4+
Copyright (c) 2017-present Tomáš Votruba (https://tomasvotruba.com)
55

66
Permission is hereby granted, free of charge, to any person
77
obtaining a copy of this software and associated documentation

Diff for: src/ChangelogContentsFactory.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ public function create(array $changelogLines): string
4343
Assert::allString($changelogLines);
4444

4545
// summarize into "Added Features" and "Bugfixes" groups
46-
$linesByCategory = [];
46+
$linesByCategory = [
47+
// set order clearly here
48+
ChangelogCategory::NEW_FEATURES => [],
49+
ChangelogCategory::BUGFIXES => [],
50+
ChangelogCategory::REMOVED => [],
51+
ChangelogCategory::SKIPPED => [],
52+
];
4753

4854
foreach ($changelogLines as $changelogLine) {
4955
foreach (self::FILTER_KEYWORDS_BY_CATEGORY as $category => $filterKeywords) {
@@ -62,6 +68,9 @@ public function create(array $changelogLines): string
6268
// remove skipped lines
6369
unset($linesByCategory[ChangelogCategory::SKIPPED]);
6470

71+
// remove empty categories
72+
$linesByCategory = array_filter($linesByCategory);
73+
6574
return $this->generateFileContentsFromGroupedItems($linesByCategory);
6675
}
6776

Diff for: tests/ChangelogContentsFactory/ChangelogContentsFactoryTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ protected function setUp(): void
1919
public function test(): void
2020
{
2121
$changelogLines = [
22-
'* Add new rule',
2322
'* Fix bug',
23+
'* Add new rule',
2424
'* Fixed another bug',
25+
'* Removed old rule',
2526
'* Enable PHPStan on tests as well + add "unused public" ([#3238](https://github.com/rectorphp/rector-src/pull/3238))',
2627
];
2728

Diff for: tests/ChangelogContentsFactory/Fixture/generated_changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@
88

99
* Fix bug
1010
* Fixed another bug
11+
12+
<br>
13+
14+
## Removed :skull:
15+
16+
* Removed old rule

0 commit comments

Comments
 (0)