Skip to content

Commit 7feeeb7

Browse files
authored
Respect CHANGELOG order in Bot PR (#1584)
1 parent 69fb8e1 commit 7feeeb7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/bin/refresh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ foreach ($services as $service => $hasChange) {
180180
$nrSection = false;
181181
$fixSection = false;
182182
$fixSectionLabel = $hasChange ? '### Added' : '### Changed';
183-
183+
$fixSectionOrder = [
184+
'### BC-BREAK', '### Removed', // Major
185+
'### Added', '### Deprecated', // Minor
186+
'### Changed', '### Fixed', '### Security', // Patch
187+
];
188+
$fixSectionIndex = array_search($fixSectionLabel, $fixSectionOrder);
184189
foreach ($changeLog as $index => $line) {
185190
if ($line === '## NOT RELEASED') {
186191
$nrSection = true;
@@ -192,16 +197,17 @@ foreach ($services as $service => $hasChange) {
192197
if (strpos($line, '## ') === 0) {
193198
break;
194199
}
200+
if (strpos($line, '### ') === 0 && array_search($line, $fixSectionOrder) > $fixSectionIndex) {
201+
break;
202+
}
203+
195204
if ($line === $fixSectionLabel) {
196205
$fixSection = true;
197206
continue;
198207
}
199208
if (!$fixSection) {
200209
continue;
201210
}
202-
if (strpos($line, '### ') === 0) {
203-
break;
204-
}
205211

206212
if ($line !== '' && false !== $index = array_search($line, $newLines, true)) {
207213
array_splice($newLines, $index, 1);

0 commit comments

Comments
 (0)