@@ -220,20 +220,40 @@ class VersionCheckCommand extends PackageLoopingCommand {
220220 final errors = < String > [];
221221
222222 final CIConfig ? ciConfig = package.parseCIConfig ();
223+ final bool usesBatchRelease = ciConfig? .isBatchRelease ?? false ;
224+
225+ // All packages with batch release enabled should have valid pending changelogs.
226+ if (usesBatchRelease) {
227+ try {
228+ package.getPendingChangelogs ();
229+ } on FormatException catch (e) {
230+ printError ('$indentation ${e .message }' );
231+ errors.add (e.message);
232+ }
233+ } else {
234+ if (package.pendingChangelogsDirectory.existsSync ()) {
235+ printError (
236+ '${indentation }Package does not use batch release but has pending changelogs.' ,
237+ );
238+ errors.add (
239+ 'Package does not use batch release but has pending changelogs.' ,
240+ );
241+ }
242+ }
243+
223244 final _CurrentVersionState versionState = await _getVersionState (
224245 package,
225246 pubspec: pubspec,
226247 );
227- final bool usesBatchRelease = ciConfig? .isBatchRelease ?? false ;
228248 // PR with post release label is going to sync changelog.md and pubspec.yaml
229- // change back to main branch. Proceed with ragular version check.
249+ // change back to main branch. Proceed with regular version check.
230250 final bool hasPostReleaseLabel = _prLabels.contains (
231251 'post-release-${pubspec .name }' ,
232252 );
233253 bool versionChanged;
234254
235255 if (usesBatchRelease && ! hasPostReleaseLabel) {
236- versionChanged = await _validateBatchRelease (
256+ versionChanged = await _validatePendingChangeForBatchReleasePackage (
237257 package: package,
238258 changedFiles: changedFiles,
239259 errors: errors,
@@ -646,25 +666,23 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
646666 } else {
647667 missingChangelogChange = true ;
648668 final CIConfig ? config = package.parseCIConfig ();
649- if (config? .isBatchRelease ?? false ) {
650- printError (
651- 'No new changelog files found in the pending_changelogs folder.\n '
669+ const useOverrideChangelogLabel =
652670 'If this PR needs an exemption from the standard policy of listing '
653671 'all changes in the CHANGELOG,\n '
654672 'comment in the PR to explain why the PR is exempt, and add (or '
655673 'ask your reviewer to add) the\n '
656- '"$_missingChangelogChangeOverrideLabel " label.\n '
674+ '"$_missingChangelogChangeOverrideLabel " label.\n ' ;
675+ if (config? .isBatchRelease ?? false ) {
676+ printError (
677+ 'No new changelog files found in the pending_changelogs folder.\n '
678+ '$useOverrideChangelogLabel '
657679 'Otherwise, please add a changelog entry with version:skip in the pending_changelogs folder as described in '
658680 'the contributing guide.\n ' ,
659681 );
660682 } else {
661683 printError (
662684 'No CHANGELOG change found.\n '
663- 'If this PR needs an exemption from the standard policy of listing '
664- 'all changes in the CHANGELOG,\n '
665- 'comment in the PR to explain why the PR is exempt, and add (or '
666- 'ask your reviewer to add) the\n '
667- '"$_missingChangelogChangeOverrideLabel " label.\n '
685+ '$useOverrideChangelogLabel '
668686 'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
669687 'the contributing guide.\n ' ,
670688 );
@@ -691,7 +709,10 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
691709 return null ;
692710 }
693711
694- Future <bool > _validateBatchRelease ({
712+ /// Validates that the pending changelog files are correct for a batch release.
713+ ///
714+ /// This should only be called for package that uses batch release.
715+ Future <bool > _validatePendingChangeForBatchReleasePackage ({
695716 required RepositoryPackage package,
696717 required List <String > changedFiles,
697718 required List <String > errors,
0 commit comments