Skip to content

Commit

Permalink
Sort categories from: new features, bugfixes and removed (#4)
Browse files Browse the repository at this point in the history
* cz

* sort categories from new features, bugfixes and removed
  • Loading branch information
TomasVotruba authored Jan 19, 2025
1 parent 1a0d956 commit 74e4df1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License
---------------

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

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
11 changes: 10 additions & 1 deletion src/ChangelogContentsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public function create(array $changelogLines): string
Assert::allString($changelogLines);

// summarize into "Added Features" and "Bugfixes" groups
$linesByCategory = [];
$linesByCategory = [
// set order clearly here
ChangelogCategory::NEW_FEATURES => [],
ChangelogCategory::BUGFIXES => [],
ChangelogCategory::REMOVED => [],
ChangelogCategory::SKIPPED => [],
];

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

// remove empty categories
$linesByCategory = array_filter($linesByCategory);

return $this->generateFileContentsFromGroupedItems($linesByCategory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ protected function setUp(): void
public function test(): void
{
$changelogLines = [
'* Add new rule',
'* Fix bug',
'* Add new rule',
'* Fixed another bug',
'* Removed old rule',
'* Enable PHPStan on tests as well + add "unused public" ([#3238](https://github.com/rectorphp/rector-src/pull/3238))',
];

Expand Down
6 changes: 6 additions & 0 deletions tests/ChangelogContentsFactory/Fixture/generated_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

* Fix bug
* Fixed another bug

<br>

## Removed :skull:

* Removed old rule

0 comments on commit 74e4df1

Please sign in to comment.