Skip to content

Commit f8fbcdb

Browse files
authored
[ci] version_check_command now checks markdown of first CHANGELOG line. (#7266)
This PR: * Modifies the `version_check_command` test so it checks the leading markdown of the first line of a CHANGELOG file, to ensure it's `'##'`. * Fixes the CHANGELOG in two packages that were allowed by the tool before this fix: * google_maps_flutter_web * interactive_media_ads ## Issues Fixes flutter/flutter#152638
1 parent 37c4b1c commit f8fbcdb

File tree

8 files changed

+54
-7
lines changed

8 files changed

+54
-7
lines changed

packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# 0.5.9
1+
## 0.5.9+1
2+
3+
* Fixes a typo in the formatting of the CHANGELOG.
4+
5+
## 0.5.9
26

37
* Updates `package:google_maps` dependency to latest (`^8.0.0`).
48
* Supports `web: ">=0.5.1 <2.0.0"`.

packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter_web
22
description: Web platform implementation of google_maps_flutter
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 0.5.9
5+
version: 0.5.9+1
66

77
environment:
88
sdk: ^3.4.0

packages/interactive_media_ads/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# 0.1.1
1+
## 0.1.1+1
2+
3+
* Fixes a typo in the formatting of the CHANGELOG.
4+
5+
## 0.1.1
26

37
* Adds iOS implementation.
48
* Adds support for setting the layout direction of the `AdDisplayContainer`.

packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
2121
*
2222
* This must match the version in pubspec.yaml.
2323
*/
24-
const val pluginVersion = "0.1.1"
24+
const val pluginVersion = "0.1.1+1"
2525
}
2626

2727
override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {

packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest {
1313
/// The current version of the `interactive_media_ads` plugin.
1414
///
1515
/// This must match the version in pubspec.yaml.
16-
static let pluginVersion = "0.1.1"
16+
static let pluginVersion = "0.1.1+1"
1717

1818
func pigeonDefaultConstructor(
1919
pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer,

packages/interactive_media_ads/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: interactive_media_ads
22
description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS.
33
repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22
5-
version: 0.1.1 # This must match the version in
5+
version: 0.1.1+1 # This must match the version in
66
# `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and
77
# `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift`
88

script/tool/lib/src/version_check_command.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
392392
}
393393
// Remove all leading mark down syntax from the version line.
394394
String? versionString = firstLineWithText?.split(' ').last;
395+
String? leadingMarkdown = firstLineWithText?.split(' ').first;
395396

396397
final String badNextErrorMessage = '${indentation}When bumping the version '
397398
'for release, the NEXT section should be incorporated into the new '
@@ -413,15 +414,18 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
413414
// CHANGELOG. That means the next version entry in the CHANGELOG should
414415
// pass the normal validation.
415416
versionString = null;
417+
leadingMarkdown = null;
416418
while (iterator.moveNext()) {
417419
if (iterator.current.trim().startsWith('## ')) {
418420
versionString = iterator.current.trim().split(' ').last;
421+
leadingMarkdown = iterator.current.trim().split(' ').first;
419422
break;
420423
}
421424
}
422425
}
423426

424-
if (versionString == null) {
427+
final bool validLeadingMarkdown = leadingMarkdown == '##';
428+
if (versionString == null || !validLeadingMarkdown) {
425429
printError('${indentation}Unable to find a version in CHANGELOG.md');
426430
print('${indentation}The current version should be on a line starting '
427431
'with "## ", either on the first non-empty line or after a "## NEXT" '

script/tool/test/version_check_command_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,41 @@ void main() {
641641
);
642642
});
643643

644+
test('fails gracefully if the first entry uses the wrong style', () async {
645+
final RepositoryPackage plugin =
646+
createFakePlugin('plugin', packagesDir, version: '1.0.0');
647+
648+
const String changelog = '''
649+
# 1.0.0
650+
* Some changes for a later release.
651+
## 0.9.0
652+
* Some earlier changes.
653+
''';
654+
plugin.changelogFile.writeAsStringSync(changelog);
655+
processRunner.mockProcessesForExecutable['git-show'] = <FakeProcessInfo>[
656+
FakeProcessInfo(MockProcess(stdout: 'version: 1.0.0')),
657+
];
658+
659+
Error? commandError;
660+
final List<String> output = await runCapturingPrint(runner, <String>[
661+
'version-check',
662+
'--base-sha=main',
663+
], errorHandler: (Error e) {
664+
commandError = e;
665+
});
666+
667+
expect(commandError, isA<ToolExit>());
668+
expect(
669+
output,
670+
containsAllInOrder(<Matcher>[
671+
contains('Unable to find a version in CHANGELOG.md'),
672+
contains('The current version should be on a line starting with '
673+
'"## ", either on the first non-empty line or after a "## NEXT" '
674+
'section.'),
675+
]),
676+
);
677+
});
678+
644679
test(
645680
'fails gracefully if the version headers are not found due to using the wrong style',
646681
() async {

0 commit comments

Comments
 (0)