Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit c820112

Browse files
Skip unchanged packages for 'minimal'
1 parent 0d42f3f commit c820112

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

script/tool/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ cd <repository root>
133133
dart run ./script/tool/bin/flutter_plugin_tools.dart update-release-info \
134134
--version=minimal \
135135
--changelog="Fixes violations of new analysis option some_new_option."
136-
--run-on-changed-packages
137136
```
138137

139-
The `minimal` option for `--version` will treat each package as either `bugfix`
140-
or `next` depending on the files that have changed in that package, so it is
141-
often the best choice for a bulk change.
138+
The `minimal` option for `--version` will skip unchanged packages, and treat
139+
each changed package as either `bugfix` or `next` depending on the files that
140+
have changed in that package, so it is often the best choice for a bulk change.
142141

143142
For cases where you know the change time, `minor` or `bugfix` will make the
144143
corresponding version bump, or `next` will update only `CHANGELOG.md` without

script/tool/lib/src/update_release_info_command.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
5757
'No version change; just adds a NEXT entry to the changelog.',
5858
_versionBugfix: 'Increments the bugfix version.',
5959
_versionMinor: 'Increments the minor version.',
60-
_versionMinimal: 'Either increments the bugfix version or uses NEXT '
61-
'depending on the files changed.',
60+
_versionMinimal: 'Depending on the changes to each package: '
61+
'increments the bugfix version (for publishable changes), '
62+
"uses NEXT (for changes that don't need to be published), "
63+
'or skips (if no changes).',
6264
});
6365
}
6466

@@ -122,7 +124,8 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
122124
String nextVersionString;
123125

124126
_VersionIncrementType? versionChange = _versionChange;
125-
// If the change type is `minimal`, determine whether a version change is
127+
128+
// If the change type is `minimal` determine what changes, if any, are
126129
// needed.
127130
if (versionChange == null &&
128131
getStringArg(_versionTypeFlag) == _versionMinimal) {
@@ -133,6 +136,10 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
133136
final PackageChangeState state = checkPackageChangeState(package,
134137
changedPaths: _changedFiles,
135138
relativePackagePath: relativePackagePath);
139+
140+
if (!state.hasChanges) {
141+
return PackageResult.skip('No changes to package');
142+
}
136143
if (state.needsVersionChange) {
137144
versionChange = _VersionIncrementType.bugfix;
138145
}

script/tool/test/update_release_info_command_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,34 @@ $originalChangelog''';
383383
expect(newChangelog, expectedChangeLog);
384384
});
385385

386+
test('skips for "minimal" when there are no changes at all', () async {
387+
final RepositoryPackage package =
388+
createFakePackage('a_package', packagesDir, version: '1.0.1');
389+
processRunner.mockProcessesForExecutable['git-diff'] = <io.Process>[
390+
MockProcess(stdout: '''
391+
packages/different_package/test/plugin_test.dart
392+
'''),
393+
];
394+
final String originalChangelog = package.changelogFile.readAsStringSync();
395+
396+
final List<String> output = await runCapturingPrint(runner, <String>[
397+
'update-release-info',
398+
'--version=minimal',
399+
'--changelog',
400+
'A change.',
401+
]);
402+
403+
final String version = package.parsePubspec().version?.toString() ?? '';
404+
expect(version, '1.0.1');
405+
expect(package.changelogFile.readAsStringSync(), originalChangelog);
406+
expect(
407+
output,
408+
containsAllInOrder(<Matcher>[
409+
contains('No changes to package'),
410+
contains('Skipped 1 package')
411+
]));
412+
});
413+
386414
test('fails if CHANGELOG.md is missing', () async {
387415
createFakePackage('a_package', packagesDir, includeCommonFiles: false);
388416

0 commit comments

Comments
 (0)