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

Commit

Permalink
Skip unchanged packages for 'minimal'
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed May 6, 2022
1 parent 0d42f3f commit c820112
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
7 changes: 3 additions & 4 deletions script/tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart update-release-info \
--version=minimal \
--changelog="Fixes violations of new analysis option some_new_option."
--run-on-changed-packages
```

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

For cases where you know the change time, `minor` or `bugfix` will make the
corresponding version bump, or `next` will update only `CHANGELOG.md` without
Expand Down
13 changes: 10 additions & 3 deletions script/tool/lib/src/update_release_info_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
'No version change; just adds a NEXT entry to the changelog.',
_versionBugfix: 'Increments the bugfix version.',
_versionMinor: 'Increments the minor version.',
_versionMinimal: 'Either increments the bugfix version or uses NEXT '
'depending on the files changed.',
_versionMinimal: 'Depending on the changes to each package: '
'increments the bugfix version (for publishable changes), '
"uses NEXT (for changes that don't need to be published), "
'or skips (if no changes).',
});
}

Expand Down Expand Up @@ -122,7 +124,8 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
String nextVersionString;

_VersionIncrementType? versionChange = _versionChange;
// If the change type is `minimal`, determine whether a version change is

// If the change type is `minimal` determine what changes, if any, are
// needed.
if (versionChange == null &&
getStringArg(_versionTypeFlag) == _versionMinimal) {
Expand All @@ -133,6 +136,10 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
final PackageChangeState state = checkPackageChangeState(package,
changedPaths: _changedFiles,
relativePackagePath: relativePackagePath);

if (!state.hasChanges) {
return PackageResult.skip('No changes to package');
}
if (state.needsVersionChange) {
versionChange = _VersionIncrementType.bugfix;
}
Expand Down
28 changes: 28 additions & 0 deletions script/tool/test/update_release_info_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,34 @@ $originalChangelog''';
expect(newChangelog, expectedChangeLog);
});

test('skips for "minimal" when there are no changes at all', () async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir, version: '1.0.1');
processRunner.mockProcessesForExecutable['git-diff'] = <io.Process>[
MockProcess(stdout: '''
packages/different_package/test/plugin_test.dart
'''),
];
final String originalChangelog = package.changelogFile.readAsStringSync();

final List<String> output = await runCapturingPrint(runner, <String>[
'update-release-info',
'--version=minimal',
'--changelog',
'A change.',
]);

final String version = package.parsePubspec().version?.toString() ?? '';
expect(version, '1.0.1');
expect(package.changelogFile.readAsStringSync(), originalChangelog);
expect(
output,
containsAllInOrder(<Matcher>[
contains('No changes to package'),
contains('Skipped 1 package')
]));
});

test('fails if CHANGELOG.md is missing', () async {
createFakePackage('a_package', packagesDir, includeCommonFiles: false);

Expand Down

0 comments on commit c820112

Please sign in to comment.