Skip to content

Commit 95f2e50

Browse files
[tool] Exempt federated impl examples from CHANGELOG (flutter#6018)
The example app of a federated example is effectively test-only code, so treat changes to it (other than the one published file) as dev-only for the purposes of deciding what to flag for CHANGELOGs.
1 parent 07d1ad3 commit 95f2e50

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

script/tool/lib/src/common/package_state_utils.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,29 @@ Future<PackageChangeState> checkPackageChangeState(
8686
continue;
8787
}
8888

89-
// Some other changes don't need version changes, but might benefit from
90-
// changelog changes.
89+
final bool isUnpublishedExampleChange =
90+
_isUnpublishedExampleChange(components, package);
91+
92+
// Since examples of federated plugin implementations are only intended
93+
// for testing purposes, any unpublished example change in one of them is
94+
// effectively a developer-only change.
95+
if (package.isFederated &&
96+
package.isPlatformImplementation &&
97+
isUnpublishedExampleChange) {
98+
continue;
99+
}
100+
101+
// Anything that is not developer-only might benefit from changelog
102+
// changes. This errs on the side of flagging, so that someone checks to
103+
// see if it should be mentioned there or not.
91104
needsChangelogChange = true;
105+
106+
// Most changes that aren't developer-only need version changes.
92107
if (
93108
// One of a few special files example will be shown on pub.dev, but
94-
// for anything else in the example publishing has no purpose.
95-
!_isUnpublishedExampleChange(components, package)) {
109+
// for anything else in the example, publishing isn't necessary (even
110+
// if it is relevant to mention in the CHANGELOG for the future).
111+
!isUnpublishedExampleChange) {
96112
needsVersionChange = true;
97113
}
98114
}

script/tool/test/common/package_state_utils_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ void main() {
231231
expect(state.needsChangelogChange, true);
232232
});
233233

234+
test(
235+
'requires neither a changelog nor version change for README.md when '
236+
'code example is present in a federated plugin implementation',
237+
() async {
238+
final RepositoryPackage package = createFakePlugin(
239+
'a_plugin_android', packagesDir.childDirectory('a_plugin'),
240+
extraFiles: <String>['example/lib/main.dart']);
241+
242+
const List<String> changedFiles = <String>[
243+
'packages/a_plugin/a_plugin_android/example/README.md',
244+
];
245+
246+
final PackageChangeState state = await checkPackageChangeState(package,
247+
changedPaths: changedFiles,
248+
relativePackagePath: 'packages/a_plugin/a_plugin_android');
249+
250+
expect(state.hasChanges, true);
251+
expect(state.needsVersionChange, false);
252+
expect(state.needsChangelogChange, false);
253+
});
254+
234255
test(
235256
'does not requires changelog or version change for build.gradle '
236257
'test-dependency-only changes', () async {

0 commit comments

Comments
 (0)