Skip to content

Commit 7923304

Browse files
authored
Move Documentation updates entries in ### Changed section (#1540)
1 parent c569eed commit 7923304

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

.github/workflows/bin/refresh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,27 @@ if ($hasChange) {
149149
foreach ($services as $service => $hasChange) {
150150
$awsServiceNames = array_merge([$service], $manifest['services'][$service]['alternative-names'] ?? []);
151151
$newLines = [];
152-
foreach ($awsServiceNames as $awsServiceName) {
153-
$sanitizedService = preg_replace('[^a-z0-9]', '', strtolower($awsServiceName));
154-
if ($hasChange) {
152+
if ($hasChange) {
153+
foreach ($awsServiceNames as $awsServiceName) {
154+
$sanitizedService = preg_replace('[^a-z0-9]', '', strtolower($awsServiceName));
155155
if (!isset($changesByService[$sanitizedService])) {
156156
continue;
157157
}
158158
foreach ($changesByService[$sanitizedService] as $change) {
159159
$newLines[] = sprintf('- AWS %s: %s', $change['type'], $change['description']);
160160
}
161-
} else {
162-
$newLines[] = '- AWS enhancement: Documentation updates.';
163161
}
162+
} else {
163+
$newLines[] = '- AWS enhancement: Documentation updates.';
164164
}
165165

166166
if (empty($newLines)) {
167167
console_log('/!\ No entry in changelog for service '.$service);
168168
$newLines[] = '- AWS api-change: TODO';
169169
}
170170

171+
$newLines = array_unique($newLines);
172+
171173
console_log('Generating CHANGELOG for '. $service);
172174
if ($service === 'Sts') {
173175
$changeLogPath = $rootDir.'/src/Core/CHANGELOG.md';
@@ -177,6 +179,8 @@ foreach ($services as $service => $hasChange) {
177179
$changeLog = explode("\n", file_get_contents($changeLogPath));
178180
$nrSection = false;
179181
$fixSection = false;
182+
$fixSectionLabel = $hasChange ? '### Added' : '### Changed';
183+
180184
foreach ($changeLog as $index => $line) {
181185
if ($line === '## NOT RELEASED') {
182186
$nrSection = true;
@@ -188,7 +192,7 @@ foreach ($services as $service => $hasChange) {
188192
if (strpos($line, '## ') === 0) {
189193
break;
190194
}
191-
if ($line === '### Added') {
195+
if ($line === $fixSectionLabel) {
192196
$fixSection = true;
193197
continue;
194198
}
@@ -213,12 +217,12 @@ foreach ($services as $service => $hasChange) {
213217
array_splice($changeLog, 2, 0, array_merge([
214218
'## NOT RELEASED',
215219
'',
216-
'### Added',
220+
$fixSectionLabel,
217221
'',
218222
], $newLines, ['']));
219223
} elseif (!$fixSection) {
220224
array_splice($changeLog, $index, 0, array_merge([
221-
'### Added',
225+
$fixSectionLabel,
222226
'',
223227
], $newLines, ['']));
224228
} else {

0 commit comments

Comments
 (0)