@@ -208,12 +208,29 @@ class VersionCheckCommand extends PackageLoopingCommand {
208208 // change back to main branch. We can proceed with ragular version check.
209209 final bool hasPostReleaseLabel =
210210 _prLabels.contains ('post-release-${pubspec .name }' );
211+ bool versionChanged;
212+
211213 if (usesBatchRelease && ! hasPostReleaseLabel) {
212214 final List <String > changedFiles =
213215 await _gitVersionFinder.getChangedFiles ();
214216 // For batch release, we only check pending changelog files.
215- errors.addAll (await _validatePendingChangelogs (package, changedFiles));
216- // The changelog and version should not be updated directly.
217+ final List <PendingChangelogEntry > allChangelogs =
218+ < PendingChangelogEntry > [];
219+ try {
220+ allChangelogs.addAll (package.getPendingChangelogs ());
221+ } on FormatException catch (e) {
222+ errors.add (e.message);
223+ return PackageResult .fail (errors);
224+ }
225+
226+ final List <PendingChangelogEntry > newEntries = allChangelogs
227+ .where ((PendingChangelogEntry entry) =>
228+ changedFiles.contains (entry.file.path))
229+ .toList ();
230+ versionChanged = newEntries.any (
231+ (PendingChangelogEntry entry) => entry.version != VersionChange .skip);
232+
233+ // The changelog.md and pubspec.yaml's version should not be updated directly.
217234 if (changedFiles.contains (package.changelogFile.path)) {
218235 errors.add ('CHANGELOG.md changed' );
219236 }
@@ -223,7 +240,6 @@ class VersionCheckCommand extends PackageLoopingCommand {
223240 }
224241 }
225242 } else {
226- bool versionChanged;
227243 switch (versionState) {
228244 case _CurrentVersionState .unchanged:
229245 versionChanged = false ;
@@ -243,16 +259,16 @@ class VersionCheckCommand extends PackageLoopingCommand {
243259 pubspec: pubspec, pubspecVersionState: versionState))) {
244260 errors.add ('CHANGELOG.md failed validation.' );
245261 }
262+ }
246263
247- // If there are no other issues, make sure that there isn't a missing
248- // change to the version and/or CHANGELOG.
249- if (getBoolArg (_checkForMissingChanges) &&
250- ! versionChanged &&
251- errors.isEmpty) {
252- final String ? error = await _checkForMissingChangeError (package);
253- if (error != null ) {
254- errors.add (error);
255- }
264+ // If there are no other issues, make sure that there isn't a missing
265+ // change to the version and/or CHANGELOG.
266+ if (getBoolArg (_checkForMissingChanges) &&
267+ ! versionChanged &&
268+ errors.isEmpty) {
269+ final String ? error = await _checkForMissingChangeError (package);
270+ if (error != null ) {
271+ errors.add (error);
256272 }
257273 }
258274
@@ -594,14 +610,28 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
594610 '"$_missingChangelogChangeOverrideLabel " label.' );
595611 } else {
596612 missingChangelogChange = true ;
597- printError ('No CHANGELOG change found.\n '
598- 'If this PR needs an exemption from the standard policy of listing '
599- 'all changes in the CHANGELOG,\n '
600- 'comment in the PR to explain why the PR is exempt, and add (or '
601- 'ask your reviewer to add) the\n '
602- '"$_missingChangelogChangeOverrideLabel " label.\n '
603- 'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
604- 'the contributing guide.\n ' );
613+ final bool isBatchRelease =
614+ package.parseCiConfig ()? .isBatchRelease ?? false ;
615+ if (isBatchRelease) {
616+ printError (
617+ 'No new changelog files found in the pending_changelogs folder.\n '
618+ 'If this PR needs an exemption from the standard policy of listing '
619+ 'all changes in the CHANGELOG,\n '
620+ 'comment in the PR to explain why the PR is exempt, and add (or '
621+ 'ask your reviewer to add) the\n '
622+ '"$_missingChangelogChangeOverrideLabel " label.\n '
623+ 'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
624+ 'the contributing guide.\n ' );
625+ } else {
626+ printError ('No CHANGELOG change found.\n '
627+ 'If this PR needs an exemption from the standard policy of listing '
628+ 'all changes in the CHANGELOG,\n '
629+ 'comment in the PR to explain why the PR is exempt, and add (or '
630+ 'ask your reviewer to add) the\n '
631+ '"$_missingChangelogChangeOverrideLabel " label.\n '
632+ 'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
633+ 'the contributing guide.\n ' );
634+ }
605635 }
606636 }
607637
@@ -621,59 +651,4 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
621651
622652 return null ;
623653 }
624-
625- Future <List <String >> _validatePendingChangelogs (
626- RepositoryPackage package, List <String > changedPaths) async {
627- final List <String > errors = < String > [];
628- List <PendingChangelogEntry > allChangelogs = < PendingChangelogEntry > [];
629- try {
630- allChangelogs = package.getPendingChangelogs ();
631- } on FormatException catch (e) {
632- errors.add (e.message);
633- return errors;
634- }
635-
636- final List <PendingChangelogEntry > newEntries = allChangelogs
637- .where ((PendingChangelogEntry entry) =>
638- changedPaths.contains (entry.file.path))
639- .toList ();
640-
641- if (newEntries.isEmpty) {
642- if (_prLabels.contains (_missingChangelogChangeOverrideLabel)) {
643- logWarning ('Ignoring lack of changelog update due to the '
644- '"$_missingChangelogChangeOverrideLabel " label.' );
645- } else {
646- errors.add ('Missing CHANGELOG file' );
647- printError (
648- 'No new changelog files found in the pending_changelogs folder.\n '
649- 'If this PR needs an exemption from the standard policy of listing '
650- 'all changes in the CHANGELOG,\n '
651- 'comment in the PR to explain why the PR is exempt, and add (or '
652- 'ask your reviewer to add) the\n '
653- '"$_missingChangelogChangeOverrideLabel " label.\n '
654- 'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
655- 'the contributing guide.\n ' );
656- }
657- } else {
658- final bool needsOverride = newEntries.every (
659- (PendingChangelogEntry entry) => entry.version == VersionChange .skip);
660- if (needsOverride) {
661- if (_prLabels.contains (_missingVersionChangeOverrideLabel)) {
662- logWarning ('Ignoring lack of version change due to the '
663- '"$_missingVersionChangeOverrideLabel " label.' );
664- } else {
665- printError (
666- 'No version change found, but the change to this package could '
667- 'not be verified to be exempt\n '
668- 'from version changes according to repository policy.\n '
669- 'If this is a false positive, please comment in '
670- 'the PR to explain why the PR\n '
671- 'is exempt, and add (or ask your reviewer to add) the '
672- '"$_missingVersionChangeOverrideLabel " label.\n ' );
673- }
674- errors.add ('Missing version change' );
675- }
676- }
677- return errors;
678- }
679654}
0 commit comments