@@ -149,25 +149,27 @@ if ($hasChange) {
149
149
foreach ($ services as $ service => $ hasChange ) {
150
150
$ awsServiceNames = array_merge ([$ service ], $ manifest ['services ' ][$ service ]['alternative-names ' ] ?? []);
151
151
$ 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 ));
155
155
if (!isset ($ changesByService [$ sanitizedService ])) {
156
156
continue ;
157
157
}
158
158
foreach ($ changesByService [$ sanitizedService ] as $ change ) {
159
159
$ newLines [] = sprintf ('- AWS %s: %s ' , $ change ['type ' ], $ change ['description ' ]);
160
160
}
161
- } else {
162
- $ newLines [] = '- AWS enhancement: Documentation updates. ' ;
163
161
}
162
+ } else {
163
+ $ newLines [] = '- AWS enhancement: Documentation updates. ' ;
164
164
}
165
165
166
166
if (empty ($ newLines )) {
167
167
console_log ('/!\ No entry in changelog for service ' .$ service );
168
168
$ newLines [] = '- AWS api-change: TODO ' ;
169
169
}
170
170
171
+ $ newLines = array_unique ($ newLines );
172
+
171
173
console_log ('Generating CHANGELOG for ' . $ service );
172
174
if ($ service === 'Sts ' ) {
173
175
$ changeLogPath = $ rootDir .'/src/Core/CHANGELOG.md ' ;
@@ -177,6 +179,8 @@ foreach ($services as $service => $hasChange) {
177
179
$ changeLog = explode ("\n" , file_get_contents ($ changeLogPath ));
178
180
$ nrSection = false ;
179
181
$ fixSection = false ;
182
+ $ fixSectionLabel = $ hasChange ? '### Added ' : '### Changed ' ;
183
+
180
184
foreach ($ changeLog as $ index => $ line ) {
181
185
if ($ line === '## NOT RELEASED ' ) {
182
186
$ nrSection = true ;
@@ -188,7 +192,7 @@ foreach ($services as $service => $hasChange) {
188
192
if (strpos ($ line , '## ' ) === 0 ) {
189
193
break ;
190
194
}
191
- if ($ line === ' ### Added ' ) {
195
+ if ($ line === $ fixSectionLabel ) {
192
196
$ fixSection = true ;
193
197
continue ;
194
198
}
@@ -213,12 +217,12 @@ foreach ($services as $service => $hasChange) {
213
217
array_splice ($ changeLog , 2 , 0 , array_merge ([
214
218
'## NOT RELEASED ' ,
215
219
'' ,
216
- ' ### Added ' ,
220
+ $ fixSectionLabel ,
217
221
'' ,
218
222
], $ newLines , ['' ]));
219
223
} elseif (!$ fixSection ) {
220
224
array_splice ($ changeLog , $ index , 0 , array_merge ([
221
- ' ### Added ' ,
225
+ $ fixSectionLabel ,
222
226
'' ,
223
227
], $ newLines , ['' ]));
224
228
} else {
0 commit comments