mirror of
https://github.com/flutter/packages.git
synced 2025-06-27 13:19:06 +08:00
[flutter_plugin_tools] Add 'main' support (#4474)
Treat `main` the same as `master` for branch-based switching, in preparation for switching the branch names in Flutter repositories. Also updates all of the tests that used `master` as the explicit base to use `main` instead; what the tests use is arbitrary, so they can be switched now even though the repo itself hasn't switched. Part of https://github.com/flutter/flutter/issues/90476
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
## NEXT
|
## 0.7.2
|
||||||
|
|
||||||
- Update Firebase Testlab deprecated test device. (Pixel 4 API 29 -> Pixel 5 API 30).
|
- Update Firebase Testlab deprecated test device. (Pixel 4 API 29 -> Pixel 5 API 30).
|
||||||
- `native-test --android`, `--ios`, and `--macos` now fail plugins that don't
|
- `native-test --android`, `--ios`, and `--macos` now fail plugins that don't
|
||||||
@ -15,6 +15,8 @@
|
|||||||
length.
|
length.
|
||||||
- Fix `license-check` when run on Windows with line ending conversion enabled.
|
- Fix `license-check` when run on Windows with line ending conversion enabled.
|
||||||
- Fixed `pubspec-check` on Windows.
|
- Fixed `pubspec-check` on Windows.
|
||||||
|
- Add support for `main` as a primary branch. `master` continues to work for
|
||||||
|
compatibility.
|
||||||
|
|
||||||
## 0.7.1
|
## 0.7.1
|
||||||
|
|
||||||
|
@ -81,7 +81,8 @@ abstract class PluginCommand extends Command<void> {
|
|||||||
argParser.addFlag(_packagesForBranchArg,
|
argParser.addFlag(_packagesForBranchArg,
|
||||||
help:
|
help:
|
||||||
'This runs on all packages (equivalent to no package selection flag)\n'
|
'This runs on all packages (equivalent to no package selection flag)\n'
|
||||||
'on master, and behaves like --run-on-changed-packages on any other branch.\n\n'
|
'on main (or master), and behaves like --run-on-changed-packages on '
|
||||||
|
'any other branch.\n\n'
|
||||||
'Cannot be combined with $_packagesArg.\n\n'
|
'Cannot be combined with $_packagesArg.\n\n'
|
||||||
'This is intended for use in CI.\n',
|
'This is intended for use in CI.\n',
|
||||||
hide: true);
|
hide: true);
|
||||||
@ -301,7 +302,7 @@ abstract class PluginCommand extends Command<void> {
|
|||||||
'only be used in a git repository.');
|
'only be used in a git repository.');
|
||||||
throw ToolExit(exitInvalidArguments);
|
throw ToolExit(exitInvalidArguments);
|
||||||
} else {
|
} else {
|
||||||
runOnChangedPackages = branch != 'master';
|
runOnChangedPackages = branch != 'master' && branch != 'main';
|
||||||
// Log the mode for auditing what was intended to run.
|
// Log the mode for auditing what was intended to run.
|
||||||
print('--$_packagesForBranchArg: running on '
|
print('--$_packagesForBranchArg: running on '
|
||||||
'${runOnChangedPackages ? 'changed' : 'all'} packages');
|
'${runOnChangedPackages ? 'changed' : 'all'} packages');
|
||||||
|
@ -24,7 +24,7 @@ class TestCommand extends PackageLoopingCommand {
|
|||||||
defaultsTo: '',
|
defaultsTo: '',
|
||||||
help:
|
help:
|
||||||
'Runs Dart unit tests in Dart VM with the given experiments enabled. '
|
'Runs Dart unit tests in Dart VM with the given experiments enabled. '
|
||||||
'See https://github.com/dart-lang/sdk/blob/master/docs/process/experimental-flags.md '
|
'See https://github.com/dart-lang/sdk/blob/main/docs/process/experimental-flags.md '
|
||||||
'for details.',
|
'for details.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,9 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
|||||||
// This method isn't called unless `version` is non-null.
|
// This method isn't called unless `version` is non-null.
|
||||||
final Version currentVersion = pubspec.version!;
|
final Version currentVersion = pubspec.version!;
|
||||||
Version? previousVersion;
|
Version? previousVersion;
|
||||||
|
String previousVersionSource;
|
||||||
if (getBoolArg(_againstPubFlag)) {
|
if (getBoolArg(_againstPubFlag)) {
|
||||||
|
previousVersionSource = 'pub';
|
||||||
previousVersion = await _fetchPreviousVersionFromPub(pubspec.name);
|
previousVersion = await _fetchPreviousVersionFromPub(pubspec.name);
|
||||||
if (previousVersion == null) {
|
if (previousVersion == null) {
|
||||||
return _CurrentVersionState.unknown;
|
return _CurrentVersionState.unknown;
|
||||||
@ -273,6 +275,7 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
|
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
|
||||||
|
previousVersionSource = await gitVersionFinder.getBaseSha();
|
||||||
previousVersion = await _getPreviousVersionFromGit(package,
|
previousVersion = await _getPreviousVersionFromGit(package,
|
||||||
gitVersionFinder: gitVersionFinder) ??
|
gitVersionFinder: gitVersionFinder) ??
|
||||||
Version.none;
|
Version.none;
|
||||||
@ -310,9 +313,8 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
|||||||
if (allowedNextVersions.containsKey(currentVersion)) {
|
if (allowedNextVersions.containsKey(currentVersion)) {
|
||||||
print('$indentation$previousVersion -> $currentVersion');
|
print('$indentation$previousVersion -> $currentVersion');
|
||||||
} else {
|
} else {
|
||||||
final String source = (getBoolArg(_againstPubFlag)) ? 'pub' : 'master';
|
|
||||||
printError('${indentation}Incorrectly updated version.\n'
|
printError('${indentation}Incorrectly updated version.\n'
|
||||||
'${indentation}HEAD: $currentVersion, $source: $previousVersion.\n'
|
'${indentation}HEAD: $currentVersion, $previousVersionSource: $previousVersion.\n'
|
||||||
'${indentation}Allowed versions: $allowedNextVersions');
|
'${indentation}Allowed versions: $allowedNextVersions');
|
||||||
return _CurrentVersionState.invalidChange;
|
return _CurrentVersionState.invalidChange;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: flutter_plugin_tools
|
name: flutter_plugin_tools
|
||||||
description: Productivity utils for flutter/plugins and flutter/packages
|
description: Productivity utils for flutter/plugins and flutter/packages
|
||||||
repository: https://github.com/flutter/plugins/tree/master/script/tool
|
repository: https://github.com/flutter/plugins/tree/master/script/tool
|
||||||
version: 0.7.1
|
version: 0.7.2
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: ^2.1.0
|
args: ^2.1.0
|
||||||
|
@ -253,7 +253,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Ensure that the command used to analyze flutter/plugins in the Dart repo:
|
// Ensure that the command used to analyze flutter/plugins in the Dart repo:
|
||||||
// https://github.com/dart-lang/sdk/blob/master/tools/bots/flutter/analyze_flutter_plugins.sh
|
// https://github.com/dart-lang/sdk/blob/main/tools/bots/flutter/analyze_flutter_plugins.sh
|
||||||
// continues to work.
|
// continues to work.
|
||||||
//
|
//
|
||||||
// DO NOT remove or modify this test without a coordination plan in place to
|
// DO NOT remove or modify this test without a coordination plan in place to
|
||||||
|
@ -246,11 +246,8 @@ void main() {
|
|||||||
test('all plugins should be tested if there are no changes.', () async {
|
test('all plugins should be tested if there are no changes.', () async {
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -264,11 +261,8 @@ void main() {
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -283,11 +277,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -302,11 +293,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -322,11 +310,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -342,11 +327,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -362,11 +344,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -382,11 +361,8 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -398,17 +374,14 @@ packages/plugin1/CHANGELOG
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin2', packagesDir);
|
createFakePlugin('plugin2', packagesDir);
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
contains(
|
contains(
|
||||||
'Running for all packages that have changed relative to "master"'),
|
'Running for all packages that have changed relative to "main"'),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||||
@ -424,11 +397,8 @@ packages/plugin1/ios/plugin1.m
|
|||||||
];
|
];
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin2', packagesDir);
|
createFakePlugin('plugin2', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||||
});
|
});
|
||||||
@ -444,11 +414,8 @@ packages/plugin2/ios/plugin2.m
|
|||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins,
|
expect(command.plugins,
|
||||||
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
@ -468,11 +435,8 @@ packages/plugin1/plugin1_web/plugin1_web.dart
|
|||||||
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
||||||
createFakePlugin('plugin2', packagesDir);
|
createFakePlugin('plugin2', packagesDir);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir);
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||||
});
|
});
|
||||||
@ -491,11 +455,8 @@ packages/plugin1/plugin1/plugin1.dart
|
|||||||
packagesDir.childDirectory('plugin1'));
|
packagesDir.childDirectory('plugin1'));
|
||||||
final Directory plugin3 = createFakePlugin(
|
final Directory plugin3 = createFakePlugin(
|
||||||
'plugin1_web', packagesDir.childDirectory('plugin1'));
|
'plugin1_web', packagesDir.childDirectory('plugin1'));
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner,
|
||||||
'sample',
|
<String>['sample', '--base-sha=main', '--run-on-changed-packages']);
|
||||||
'--base-sha=master',
|
|
||||||
'--run-on-changed-packages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
command.plugins,
|
command.plugins,
|
||||||
@ -518,7 +479,7 @@ packages/plugin3/plugin3.dart
|
|||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner, <String>[
|
||||||
'sample',
|
'sample',
|
||||||
'--exclude=plugin2,plugin3',
|
'--exclude=plugin2,plugin3',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
'--run-on-changed-packages'
|
'--run-on-changed-packages'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -549,6 +510,28 @@ packages/plugin3/plugin3.dart
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('tests all packages on main', () async {
|
||||||
|
processRunner.mockProcessesForExecutable['git-diff'] = <Process>[
|
||||||
|
MockProcess(stdout: 'packages/plugin1/plugin1.dart'),
|
||||||
|
];
|
||||||
|
processRunner.mockProcessesForExecutable['git-rev-parse'] = <Process>[
|
||||||
|
MockProcess(stdout: 'main'),
|
||||||
|
];
|
||||||
|
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
|
||||||
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(
|
||||||
|
runner, <String>['sample', '--packages-for-branch']);
|
||||||
|
|
||||||
|
expect(command.plugins,
|
||||||
|
unorderedEquals(<String>[plugin1.path, plugin2.path]));
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<Matcher>[
|
||||||
|
contains('--packages-for-branch: running on all packages'),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
test('tests all packages on master', () async {
|
test('tests all packages on master', () async {
|
||||||
processRunner.mockProcessesForExecutable['git-diff'] = <Process>[
|
processRunner.mockProcessesForExecutable['git-diff'] = <Process>[
|
||||||
MockProcess(stdout: 'packages/plugin1/plugin1.dart'),
|
MockProcess(stdout: 'packages/plugin1/plugin1.dart'),
|
||||||
|
@ -38,7 +38,7 @@ String _headerSection(
|
|||||||
'flutter',
|
'flutter',
|
||||||
if (isPlugin) 'plugins' else 'packages',
|
if (isPlugin) 'plugins' else 'packages',
|
||||||
'tree',
|
'tree',
|
||||||
'master',
|
'main',
|
||||||
'packages',
|
'packages',
|
||||||
repositoryPath,
|
repositoryPath,
|
||||||
];
|
];
|
||||||
|
@ -22,15 +22,15 @@ import 'mocks.dart';
|
|||||||
import 'util.dart';
|
import 'util.dart';
|
||||||
|
|
||||||
void testAllowedVersion(
|
void testAllowedVersion(
|
||||||
String masterVersion,
|
String mainVersion,
|
||||||
String headVersion, {
|
String headVersion, {
|
||||||
bool allowed = true,
|
bool allowed = true,
|
||||||
NextVersionType? nextVersionType,
|
NextVersionType? nextVersionType,
|
||||||
}) {
|
}) {
|
||||||
final Version master = Version.parse(masterVersion);
|
final Version main = Version.parse(mainVersion);
|
||||||
final Version head = Version.parse(headVersion);
|
final Version head = Version.parse(headVersion);
|
||||||
final Map<Version, NextVersionType> allowedVersions =
|
final Map<Version, NextVersionType> allowedVersions =
|
||||||
getAllowedNextVersions(master, newVersion: head);
|
getAllowedNextVersions(main, newVersion: head);
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
expect(allowedVersions, contains(head));
|
expect(allowedVersions, contains(head));
|
||||||
if (nextVersionType != null) {
|
if (nextVersionType != null) {
|
||||||
@ -109,10 +109,10 @@ void main() {
|
|||||||
test('allows valid version', () async {
|
test('allows valid version', () async {
|
||||||
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
@ -125,17 +125,17 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
gitDirCommands,
|
gitDirCommands,
|
||||||
containsAll(<Matcher>[
|
containsAll(<Matcher>[
|
||||||
equals(<String>['show', 'master:packages/plugin/pubspec.yaml']),
|
equals(<String>['show', 'main:packages/plugin/pubspec.yaml']),
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('denies invalid version', () async {
|
test('denies invalid version', () async {
|
||||||
createFakePlugin('plugin', packagesDir, version: '0.2.0');
|
createFakePlugin('plugin', packagesDir, version: '0.2.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
'main:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
||||||
};
|
};
|
||||||
final Future<List<String>> result = runCapturingPrint(
|
final Future<List<String>> result = runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
result,
|
result,
|
||||||
@ -145,7 +145,7 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
gitDirCommands,
|
gitDirCommands,
|
||||||
containsAll(<Matcher>[
|
containsAll(<Matcher>[
|
||||||
equals(<String>['show', 'master:packages/plugin/pubspec.yaml']),
|
equals(<String>['show', 'main:packages/plugin/pubspec.yaml']),
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -229,11 +229,11 @@ void main() {
|
|||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
version: '1.1.0');
|
version: '1.1.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'main:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
@ -247,7 +247,7 @@ void main() {
|
|||||||
containsAll(<Matcher>[
|
containsAll(<Matcher>[
|
||||||
equals(<String>[
|
equals(<String>[
|
||||||
'show',
|
'show',
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml'
|
'main:packages/plugin_platform_interface/pubspec.yaml'
|
||||||
]),
|
]),
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
@ -257,11 +257,11 @@ void main() {
|
|||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
version: '2.0.0');
|
version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'main:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final Future<List<String>> output = runCapturingPrint(
|
final Future<List<String>> output = runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
await expectLater(
|
await expectLater(
|
||||||
output,
|
output,
|
||||||
throwsA(isA<ToolExit>()),
|
throwsA(isA<ToolExit>()),
|
||||||
@ -272,7 +272,7 @@ void main() {
|
|||||||
containsAll(<Matcher>[
|
containsAll(<Matcher>[
|
||||||
equals(<String>[
|
equals(<String>[
|
||||||
'show',
|
'show',
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml'
|
'main:packages/plugin_platform_interface/pubspec.yaml'
|
||||||
]),
|
]),
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
@ -282,7 +282,7 @@ void main() {
|
|||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
version: '2.0.0');
|
version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'main:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final File changeDescriptionFile =
|
final File changeDescriptionFile =
|
||||||
@ -297,7 +297,7 @@ This is necessary because of X, Y, and Z
|
|||||||
## Another section''');
|
## Another section''');
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'version-check',
|
'version-check',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
'--change-description-file=${changeDescriptionFile.path}'
|
'--change-description-file=${changeDescriptionFile.path}'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -317,14 +317,14 @@ This is necessary because of X, Y, and Z
|
|||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
version: '2.0.0');
|
version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'main:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'version-check',
|
'version-check',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
'--change-description-file=a_missing_file.txt'
|
'--change-description-file=a_missing_file.txt'
|
||||||
], errorHandler: (Error e) {
|
], errorHandler: (Error e) {
|
||||||
commandError = e;
|
commandError = e;
|
||||||
@ -344,12 +344,12 @@ This is necessary because of X, Y, and Z
|
|||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
version: '2.0.0');
|
version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'main:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'version-check',
|
'version-check',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
'--ignore-platform-interface-breaks'
|
'--ignore-platform-interface-breaks'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
@ -393,11 +393,9 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -422,7 +420,7 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
@ -445,11 +443,9 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -477,11 +473,11 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=main']);
|
||||||
await expectLater(
|
await expectLater(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
@ -506,11 +502,9 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -541,15 +535,13 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -578,15 +570,13 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -615,13 +605,13 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'version-check',
|
'version-check',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
], errorHandler: (Error e) {
|
], errorHandler: (Error e) {
|
||||||
commandError = e;
|
commandError = e;
|
||||||
});
|
});
|
||||||
@ -648,13 +638,13 @@ This is necessary because of X, Y, and Z
|
|||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'version-check',
|
'version-check',
|
||||||
'--base-sha=master',
|
'--base-sha=main',
|
||||||
], errorHandler: (Error e) {
|
], errorHandler: (Error e) {
|
||||||
commandError = e;
|
commandError = e;
|
||||||
});
|
});
|
||||||
@ -680,10 +670,10 @@ This is necessary because of X, Y, and Z
|
|||||||
|
|
||||||
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(runner,
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
<String>['version-check', '--base-sha=master', '--against-pub']);
|
<String>['version-check', '--base-sha=main', '--against-pub']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
@ -704,15 +694,13 @@ This is necessary because of X, Y, and Z
|
|||||||
|
|
||||||
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> result = await runCapturingPrint(runner, <String>[
|
final List<String> result = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -736,14 +724,12 @@ ${indentation}Allowed versions: {1.0.0: NextVersionType.BREAKING_MAJOR, 0.1.0: N
|
|||||||
|
|
||||||
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> result = await runCapturingPrint(runner, <String>[
|
final List<String> result = await runCapturingPrint(
|
||||||
'version-check',
|
runner, <String>['version-check', '--base-sha=main', '--against-pub'],
|
||||||
'--base-sha=master',
|
errorHandler: (Error e) {
|
||||||
'--against-pub'
|
|
||||||
], errorHandler: (Error e) {
|
|
||||||
expect(e, isA<ToolExit>());
|
expect(e, isA<ToolExit>());
|
||||||
hasError = true;
|
hasError = true;
|
||||||
});
|
});
|
||||||
@ -767,10 +753,10 @@ ${indentation}HTTP response: null
|
|||||||
|
|
||||||
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
createFakePlugin('plugin', packagesDir, version: '2.0.0');
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'main:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
};
|
};
|
||||||
final List<String> result = await runCapturingPrint(runner,
|
final List<String> result = await runCapturingPrint(runner,
|
||||||
<String>['version-check', '--base-sha=master', '--against-pub']);
|
<String>['version-check', '--base-sha=main', '--against-pub']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
result,
|
result,
|
||||||
|
Reference in New Issue
Block a user