Skip to content

Commit ba282f7

Browse files
committed
[ci] Add update-release-info command suggestion when version check fails
1 parent c75b87c commit ba282f7

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

script/tool/lib/src/version_check_command.dart

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,20 +547,22 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
547547
return null;
548548
}
549549

550+
bool missingVersionChange = false;
551+
bool missingChangelogChange = false;
550552
if (state.needsVersionChange) {
551553
if (_prLabels.contains(_missingVersionChangeOverrideLabel)) {
552554
logWarning('Ignoring lack of version change due to the '
553555
'"$_missingVersionChangeOverrideLabel" label.');
554556
} else {
557+
missingVersionChange = true;
555558
printError(
556559
'No version change found, but the change to this package could '
557560
'not be verified to be exempt\n'
558561
'from version changes according to repository policy.\n'
559562
'If this is a false positive, please comment in '
560563
'the PR to explain why the PR\n'
561564
'is exempt, and add (or ask your reviewer to add) the '
562-
'"$_missingVersionChangeOverrideLabel" label.');
563-
return 'Missing version change';
565+
'"$_missingVersionChangeOverrideLabel" label.\n');
564566
}
565567
}
566568

@@ -569,18 +571,33 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
569571
logWarning('Ignoring lack of CHANGELOG update due to the '
570572
'"$_missingChangelogChangeOverrideLabel" label.');
571573
} else {
574+
missingChangelogChange = true;
572575
printError('No CHANGELOG change found.\n'
573576
'If this PR needs an exemption from the standard policy of listing '
574577
'all changes in the CHANGELOG,\n'
575578
'comment in the PR to explain why the PR is exempt, and add (or '
576579
'ask your reviewer to add) the\n'
577580
'"$_missingChangelogChangeOverrideLabel" label.\n'
578581
'Otherwise, please add a NEXT entry in the CHANGELOG as described in '
579-
'the contributing guide.');
580-
return 'Missing CHANGELOG change';
582+
'the contributing guide.\n');
581583
}
582584
}
583585

586+
if (missingVersionChange && missingChangelogChange) {
587+
printError('If this PR is not exempt, you may update the version and '
588+
'CHANGELOG with the "update-release-info" command. Example:\n'
589+
'\$ dart run script/tool/bin/flutter_plugin_tools.dart update-release-info \\\n'
590+
'\t--version=minimal \\\n'
591+
'\t--base-branch=upstream/main \\\n'
592+
'\t--changelog="Description of the change."');
593+
}
594+
if (missingVersionChange) {
595+
return 'Missing version change';
596+
}
597+
if (missingChangelogChange) {
598+
return 'Missing CHANGELOG change';
599+
}
600+
584601
return null;
585602
}
586603
}

script/tool/test/version_check_command_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,8 @@ void main() {
787787
});
788788

789789
test(
790-
'fails if a version change is missing from a change that does not '
791-
'pass the exemption check', () async {
790+
'fails if a version and CHANGELOG change is missing from a change '
791+
'that does not pass the exemption check', () async {
792792
final RepositoryPackage plugin =
793793
createFakePlugin('plugin', packagesDir, version: '1.0.0');
794794

@@ -819,6 +819,8 @@ packages/plugin/lib/plugin.dart
819819
output,
820820
containsAllInOrder(<Matcher>[
821821
contains('No version change found'),
822+
contains('No CHANGELOG change found.'),
823+
contains('"update-release-info" command'),
822824
contains('plugin:\n'
823825
' Missing version change'),
824826
]),

0 commit comments

Comments
 (0)