Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -19,11 +19,7 @@ Future<void> main(List<String> args) async {
|
||||
const FileSystem fileSystem = LocalFileSystem();
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
const Platform platform = LocalPlatform();
|
||||
final Stdio stdio = VerboseStdio(
|
||||
stdout: io.stdout,
|
||||
stderr: io.stderr,
|
||||
stdin: io.stdin,
|
||||
);
|
||||
final Stdio stdio = VerboseStdio(stdout: io.stdout, stderr: io.stderr, stdin: io.stdin);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: _localFlutterRoot.parent,
|
||||
@@ -35,34 +31,23 @@ Future<void> main(List<String> args) async {
|
||||
final CommandRunner<void> runner = CommandRunner<void>(
|
||||
'conductor',
|
||||
'A tool for coordinating Flutter releases. For more documentation on '
|
||||
'usage, please see $readmeUrl.',
|
||||
'usage, please see $readmeUrl.',
|
||||
usageLineLength: 80,
|
||||
);
|
||||
|
||||
final String conductorVersion = (await const Git(processManager).getOutput(
|
||||
<String>['rev-parse'],
|
||||
'Get the revision of the current Flutter SDK',
|
||||
workingDirectory: _localFlutterRoot.path,
|
||||
)).trim();
|
||||
final String conductorVersion =
|
||||
(await const Git(processManager).getOutput(
|
||||
<String>['rev-parse'],
|
||||
'Get the revision of the current Flutter SDK',
|
||||
workingDirectory: _localFlutterRoot.path,
|
||||
)).trim();
|
||||
|
||||
<Command<void>>[
|
||||
StatusCommand(
|
||||
checkouts: checkouts,
|
||||
),
|
||||
StartCommand(
|
||||
checkouts: checkouts,
|
||||
conductorVersion: conductorVersion,
|
||||
),
|
||||
CleanCommand(
|
||||
checkouts: checkouts,
|
||||
),
|
||||
CandidatesCommand(
|
||||
checkouts: checkouts,
|
||||
flutterRoot: _localFlutterRoot,
|
||||
),
|
||||
NextCommand(
|
||||
checkouts: checkouts,
|
||||
),
|
||||
StatusCommand(checkouts: checkouts),
|
||||
StartCommand(checkouts: checkouts, conductorVersion: conductorVersion),
|
||||
CleanCommand(checkouts: checkouts),
|
||||
CandidatesCommand(checkouts: checkouts, flutterRoot: _localFlutterRoot),
|
||||
NextCommand(checkouts: checkouts),
|
||||
].forEach(runner.addCommand);
|
||||
|
||||
if (!assertsEnabled()) {
|
||||
|
||||
@@ -29,14 +29,11 @@ Future<void> run(
|
||||
ProcessManager processManager = const LocalProcessManager(),
|
||||
}) async {
|
||||
final ArgParser parser = ArgParser();
|
||||
parser.addOption(
|
||||
kTokenOption,
|
||||
help: 'Path to GitHub access token file.',
|
||||
mandatory: true,
|
||||
);
|
||||
parser.addOption(kTokenOption, help: 'Path to GitHub access token file.', mandatory: true);
|
||||
parser.addOption(
|
||||
kGithubClient,
|
||||
help: 'Path to GitHub CLI client. If not provided, it is assumed `gh` is '
|
||||
help:
|
||||
'Path to GitHub CLI client. If not provided, it is assumed `gh` is '
|
||||
'present on the PATH.',
|
||||
);
|
||||
parser.addOption(
|
||||
@@ -139,6 +136,4 @@ Directory get _localFlutterRoot {
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
void validateTokenFile(String filePath, [FileSystem fs = const LocalFileSystem()]) {
|
||||
|
||||
}
|
||||
void validateTokenFile(String filePath, [FileSystem fs = const LocalFileSystem()]) {}
|
||||
|
||||
@@ -15,10 +15,9 @@ import './version.dart';
|
||||
const String kRemote = 'remote';
|
||||
|
||||
class CandidatesCommand extends Command<void> {
|
||||
CandidatesCommand({
|
||||
required this.flutterRoot,
|
||||
required this.checkouts,
|
||||
}) : git = Git(checkouts.processManager), stdio = checkouts.stdio {
|
||||
CandidatesCommand({required this.flutterRoot, required this.checkouts})
|
||||
: git = Git(checkouts.processManager),
|
||||
stdio = checkouts.stdio {
|
||||
argParser.addOption(
|
||||
kRemote,
|
||||
help: 'Which remote name to query for branches.',
|
||||
@@ -56,13 +55,7 @@ class CandidatesCommand extends Command<void> {
|
||||
stdio.printStatus('currentVersion = $currentVersion');
|
||||
|
||||
final List<String> branches = (await git.getOutput(
|
||||
<String>[
|
||||
'branch',
|
||||
'--no-color',
|
||||
'--remotes',
|
||||
'--list',
|
||||
'${results[kRemote]}/*',
|
||||
],
|
||||
<String>['branch', '--no-color', '--remotes', '--list', '${results[kRemote]}/*'],
|
||||
'List all remote branches',
|
||||
workingDirectory: flutterRoot.path,
|
||||
)).split('\n');
|
||||
|
||||
@@ -19,16 +19,12 @@ const String kStateOption = 'state-file';
|
||||
///
|
||||
/// If the release was not completed, this command will abort the release.
|
||||
class CleanCommand extends Command<void> {
|
||||
CleanCommand({
|
||||
required this.checkouts,
|
||||
}) : platform = checkouts.platform,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
CleanCommand({required this.checkouts})
|
||||
: platform = checkouts.platform,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
final String defaultPath = defaultStateFilePath(platform);
|
||||
argParser.addFlag(
|
||||
kYesFlag,
|
||||
help: 'Override confirmation checks.',
|
||||
);
|
||||
argParser.addFlag(kYesFlag, help: 'Override confirmation checks.');
|
||||
argParser.addOption(
|
||||
kStateOption,
|
||||
defaultsTo: defaultPath,
|
||||
@@ -45,7 +41,8 @@ class CleanCommand extends Command<void> {
|
||||
String get name => 'clean';
|
||||
|
||||
@override
|
||||
String get description => 'Cleanup persistent state file. '
|
||||
String get description =>
|
||||
'Cleanup persistent state file. '
|
||||
'This will abort a work in progress release.';
|
||||
|
||||
@override
|
||||
@@ -70,9 +67,7 @@ class CleanCommand extends Command<void> {
|
||||
}
|
||||
stdio.printStatus('Deleting persistent state file ${stateFile.path}...');
|
||||
|
||||
final CleanContext cleanContext = CleanContext(
|
||||
stateFile: stateFile,
|
||||
);
|
||||
final CleanContext cleanContext = CleanContext(stateFile: stateFile);
|
||||
return cleanContext.run();
|
||||
}
|
||||
}
|
||||
@@ -81,9 +76,7 @@ class CleanCommand extends Command<void> {
|
||||
///
|
||||
/// This is a frontend-agnostic implementation.
|
||||
class CleanContext {
|
||||
CleanContext({
|
||||
required this.stateFile,
|
||||
});
|
||||
CleanContext({required this.stateFile});
|
||||
|
||||
final File stateFile;
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@ import 'stdio.dart' show Stdio;
|
||||
/// Different frontends (e.g. CLI vs desktop) can share [Context]s, although
|
||||
/// methods for capturing user interaction may be overridden.
|
||||
abstract class Context {
|
||||
const Context({
|
||||
required this.checkouts,
|
||||
required this.stateFile,
|
||||
});
|
||||
const Context({required this.checkouts, required this.stateFile});
|
||||
|
||||
final Checkouts checkouts;
|
||||
final File stateFile;
|
||||
@@ -38,9 +35,7 @@ abstract class Context {
|
||||
if (firstChar == 'N') {
|
||||
return false;
|
||||
}
|
||||
throw ConductorException(
|
||||
'Unknown user input (expected "y" or "n"): $response',
|
||||
);
|
||||
throw ConductorException('Unknown user input (expected "y" or "n"): $response');
|
||||
}
|
||||
|
||||
/// Save the release's [state].
|
||||
|
||||
@@ -14,32 +14,32 @@ const String kForceFlag = 'force';
|
||||
|
||||
const List<String> kBaseReleaseChannels = <String>['stable', 'beta'];
|
||||
|
||||
const List<String> kReleaseChannels = <String>[...kBaseReleaseChannels, FrameworkRepository.defaultBranch];
|
||||
const List<String> kReleaseChannels = <String>[
|
||||
...kBaseReleaseChannels,
|
||||
FrameworkRepository.defaultBranch,
|
||||
];
|
||||
|
||||
const String kReleaseDocumentationUrl = 'https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md';
|
||||
const String kReleaseDocumentationUrl =
|
||||
'https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md';
|
||||
|
||||
const String kLuciPackagingConsoleLink = 'https://ci.chromium.org/p/dart-internal/g/flutter_packaging/console';
|
||||
const String kLuciPackagingConsoleLink =
|
||||
'https://ci.chromium.org/p/dart-internal/g/flutter_packaging/console';
|
||||
|
||||
const String kWebsiteReleasesUrl = 'https://docs.flutter.dev/development/tools/sdk/releases';
|
||||
|
||||
const String discordReleaseChannel =
|
||||
'https://discord.com/channels/608014603317936148/783492179922124850';
|
||||
|
||||
const String flutterReleaseHotline =
|
||||
'https://mail.google.com/chat/u/0/#chat/space/AAAA6RKcK2k';
|
||||
const String flutterReleaseHotline = 'https://mail.google.com/chat/u/0/#chat/space/AAAA6RKcK2k';
|
||||
|
||||
const String hotfixToStableWiki =
|
||||
'https://github.com/flutter/flutter/blob/main/CHANGELOG.md';
|
||||
const String hotfixToStableWiki = 'https://github.com/flutter/flutter/blob/main/CHANGELOG.md';
|
||||
|
||||
const String flutterAnnounceGroup =
|
||||
'https://groups.google.com/g/flutter-announce';
|
||||
const String flutterAnnounceGroup = 'https://groups.google.com/g/flutter-announce';
|
||||
|
||||
const String hotfixDocumentationBestPractices =
|
||||
'https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md';
|
||||
|
||||
final RegExp releaseCandidateBranchRegex = RegExp(
|
||||
r'flutter-(\d+)\.(\d+)-candidate\.(\d+)',
|
||||
);
|
||||
final RegExp releaseCandidateBranchRegex = RegExp(r'flutter-(\d+)\.(\d+)-candidate\.(\d+)');
|
||||
|
||||
/// Cast a dynamic to String and trim.
|
||||
String stdoutToString(dynamic input) {
|
||||
@@ -92,15 +92,13 @@ String? getValueFromEnvOrArgs(
|
||||
if (allowNull) {
|
||||
return null;
|
||||
}
|
||||
throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName '
|
||||
'to be provided!');
|
||||
throw ConductorException(
|
||||
'Expected either the CLI arg --$name or the environment variable $envName '
|
||||
'to be provided!',
|
||||
);
|
||||
}
|
||||
|
||||
bool getBoolFromEnvOrArgs(
|
||||
String name,
|
||||
ArgResults argResults,
|
||||
Map<String, String> env,
|
||||
) {
|
||||
bool getBoolFromEnvOrArgs(String name, ArgResults argResults, Map<String, String> env) {
|
||||
final String envName = fromArgToEnvName(name);
|
||||
if (env[envName] != null) {
|
||||
return env[envName]?.toUpperCase() == 'TRUE';
|
||||
@@ -117,11 +115,7 @@ bool getBoolFromEnvOrArgs(
|
||||
///
|
||||
/// The environment is favored over CLI args since the latter can have a default
|
||||
/// value, which the environment should be able to override.
|
||||
List<String> getValuesFromEnvOrArgs(
|
||||
String name,
|
||||
ArgResults argResults,
|
||||
Map<String, String> env,
|
||||
) {
|
||||
List<String> getValuesFromEnvOrArgs(String name, ArgResults argResults, Map<String, String> env) {
|
||||
final String envName = fromArgToEnvName(name);
|
||||
if (env[envName] != null && env[envName] != '') {
|
||||
return env[envName]!.split(',');
|
||||
@@ -131,8 +125,10 @@ List<String> getValuesFromEnvOrArgs(
|
||||
return argValues;
|
||||
}
|
||||
|
||||
throw ConductorException('Expected either the CLI arg --$name or the environment variable $envName '
|
||||
'to be provided!');
|
||||
throw ConductorException(
|
||||
'Expected either the CLI arg --$name or the environment variable $envName '
|
||||
'to be provided!',
|
||||
);
|
||||
}
|
||||
|
||||
/// Translate CLI arg names to env variable names.
|
||||
@@ -154,14 +150,18 @@ String getNewPrLink({
|
||||
assert(state.releaseVersion.isNotEmpty);
|
||||
final (pb.Repository repository, String repoLabel) = switch (repoName) {
|
||||
'flutter' => (state.framework, 'Framework'),
|
||||
'engine' => (state.engine, 'Engine'),
|
||||
_ => throw ConductorException('Expected repoName to be one of flutter or engine but got $repoName.'),
|
||||
'engine' => (state.engine, 'Engine'),
|
||||
_ =>
|
||||
throw ConductorException(
|
||||
'Expected repoName to be one of flutter or engine but got $repoName.',
|
||||
),
|
||||
};
|
||||
final String candidateBranch = repository.candidateBranch;
|
||||
final String workingBranch = repository.workingBranch;
|
||||
assert(candidateBranch.isNotEmpty);
|
||||
assert(workingBranch.isNotEmpty);
|
||||
final String title = '[flutter_releases] Flutter ${state.releaseChannel} '
|
||||
final String title =
|
||||
'[flutter_releases] Flutter ${state.releaseChannel} '
|
||||
'${state.releaseVersion} $repoLabel Cherrypicks';
|
||||
final StringBuffer body = StringBuffer();
|
||||
body.write('''
|
||||
@@ -174,7 +174,9 @@ String getNewPrLink({
|
||||
if (state.engine.dartRevision.isNotEmpty) {
|
||||
// shorten hashes to make final link manageable
|
||||
// prefix with github org/repo so GitHub will auto-generate a hyperlink
|
||||
body.writeln('- Roll dart revision: dart-lang/sdk@${state.engine.dartRevision.substring(0, 9)}');
|
||||
body.writeln(
|
||||
'- Roll dart revision: dart-lang/sdk@${state.engine.dartRevision.substring(0, 9)}',
|
||||
);
|
||||
}
|
||||
for (final pb.Cherrypick cp in state.engine.cherrypicks) {
|
||||
// Only list commits that map to a commit that exists upstream.
|
||||
|
||||
@@ -24,9 +24,7 @@ const String kYesFlag = 'yes';
|
||||
/// which phase of the release the user is currently in. This is implemented
|
||||
/// with a switch case statement.
|
||||
class NextCommand extends Command<void> {
|
||||
NextCommand({
|
||||
required this.checkouts,
|
||||
}) {
|
||||
NextCommand({required this.checkouts}) {
|
||||
final String defaultPath = state_import.defaultStateFilePath(checkouts.platform);
|
||||
argParser.addOption(
|
||||
kStateOption,
|
||||
@@ -38,10 +36,7 @@ class NextCommand extends Command<void> {
|
||||
help: 'Auto-accept any confirmation prompts.',
|
||||
hide: true, // primarily for integration testing
|
||||
);
|
||||
argParser.addFlag(
|
||||
kForceFlag,
|
||||
help: 'Force push when updating remote git branches.',
|
||||
);
|
||||
argParser.addFlag(kForceFlag, help: 'Force push when updating remote git branches.');
|
||||
}
|
||||
|
||||
final Checkouts checkouts;
|
||||
@@ -56,9 +51,7 @@ class NextCommand extends Command<void> {
|
||||
Future<void> run() async {
|
||||
final File stateFile = checkouts.fileSystem.file(argResults![kStateOption]);
|
||||
if (!stateFile.existsSync()) {
|
||||
throw ConductorException(
|
||||
'No persistent state file found at ${stateFile.path}.',
|
||||
);
|
||||
throw ConductorException('No persistent state file found at ${stateFile.path}.');
|
||||
}
|
||||
final pb.ConductorState state = state_import.readStateFromFile(stateFile);
|
||||
|
||||
@@ -95,15 +88,13 @@ class NextContext extends Context {
|
||||
case pb.ReleasePhase.APPLY_ENGINE_CHERRYPICKS:
|
||||
final Remote upstream = Remote.upstream(state.engine.upstream.url);
|
||||
final EngineRepository engine = EngineRepository(
|
||||
checkouts,
|
||||
initialRef: state.engine.workingBranch,
|
||||
upstreamRemote: upstream,
|
||||
previousCheckoutLocation: state.engine.checkoutPath,
|
||||
checkouts,
|
||||
initialRef: state.engine.workingBranch,
|
||||
upstreamRemote: upstream,
|
||||
previousCheckoutLocation: state.engine.checkoutPath,
|
||||
);
|
||||
if (!state_import.requiresEnginePR(state)) {
|
||||
stdio.printStatus(
|
||||
'This release has no engine cherrypicks. No Engine PR is necessary.\n',
|
||||
);
|
||||
stdio.printStatus('This release has no engine cherrypicks. No Engine PR is necessary.\n');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -116,12 +107,18 @@ class NextContext extends Context {
|
||||
stdio.printStatus('All engine cherrypicks have been auto-applied by the conductor.\n');
|
||||
} else {
|
||||
if (unappliedCherrypicks.length == 1) {
|
||||
stdio.printStatus('There was ${unappliedCherrypicks.length} cherrypick that was not auto-applied.');
|
||||
stdio.printStatus(
|
||||
'There was ${unappliedCherrypicks.length} cherrypick that was not auto-applied.',
|
||||
);
|
||||
} else {
|
||||
stdio.printStatus('There were ${unappliedCherrypicks.length} cherrypicks that were not auto-applied.');
|
||||
stdio.printStatus(
|
||||
'There were ${unappliedCherrypicks.length} cherrypicks that were not auto-applied.',
|
||||
);
|
||||
}
|
||||
stdio.printStatus('These must be applied manually in the directory '
|
||||
'${state.engine.checkoutPath} before proceeding.\n');
|
||||
stdio.printStatus(
|
||||
'These must be applied manually in the directory '
|
||||
'${state.engine.checkoutPath} before proceeding.\n',
|
||||
);
|
||||
}
|
||||
if (!autoAccept) {
|
||||
final bool response = await prompt(
|
||||
@@ -141,7 +138,7 @@ class NextContext extends Context {
|
||||
if (!autoAccept) {
|
||||
final bool response = await prompt(
|
||||
'Has CI passed for the engine PR?\n\n'
|
||||
'${state_import.luciConsoleLink(state.engine.candidateBranch, 'engine')}'
|
||||
'${state_import.luciConsoleLink(state.engine.candidateBranch, 'engine')}',
|
||||
);
|
||||
if (!response) {
|
||||
stdio.printError('Aborting command.');
|
||||
@@ -152,11 +149,11 @@ class NextContext extends Context {
|
||||
case pb.ReleasePhase.APPLY_FRAMEWORK_CHERRYPICKS:
|
||||
final Remote engineUpstreamRemote = Remote.upstream(state.engine.upstream.url);
|
||||
final EngineRepository engine = EngineRepository(
|
||||
checkouts,
|
||||
// We explicitly want to check out the merged version from upstream
|
||||
initialRef: '${engineUpstreamRemote.name}/${state.engine.candidateBranch}',
|
||||
upstreamRemote: engineUpstreamRemote,
|
||||
previousCheckoutLocation: state.engine.checkoutPath,
|
||||
checkouts,
|
||||
// We explicitly want to check out the merged version from upstream
|
||||
initialRef: '${engineUpstreamRemote.name}/${state.engine.candidateBranch}',
|
||||
upstreamRemote: engineUpstreamRemote,
|
||||
previousCheckoutLocation: state.engine.checkoutPath,
|
||||
);
|
||||
|
||||
final String engineRevision = await engine.reverseParse('HEAD');
|
||||
@@ -169,29 +166,33 @@ class NextContext extends Context {
|
||||
previousCheckoutLocation: state.framework.checkoutPath,
|
||||
);
|
||||
stdio.printStatus('Writing candidate branch...');
|
||||
bool needsCommit = await framework.updateCandidateBranchVersion(state.framework.candidateBranch);
|
||||
bool needsCommit = await framework.updateCandidateBranchVersion(
|
||||
state.framework.candidateBranch,
|
||||
);
|
||||
if (needsCommit) {
|
||||
final String revision = await framework.commit(
|
||||
'Create candidate branch version ${state.framework.candidateBranch} for ${state.releaseChannel}',
|
||||
addFirst: true,
|
||||
'Create candidate branch version ${state.framework.candidateBranch} for ${state.releaseChannel}',
|
||||
addFirst: true,
|
||||
);
|
||||
// append to list of cherrypicks so we know a PR is required
|
||||
state.framework.cherrypicks.add(pb.Cherrypick.create()
|
||||
..appliedRevision = revision
|
||||
..state = pb.CherrypickState.COMPLETED
|
||||
state.framework.cherrypicks.add(
|
||||
pb.Cherrypick.create()
|
||||
..appliedRevision = revision
|
||||
..state = pb.CherrypickState.COMPLETED,
|
||||
);
|
||||
}
|
||||
stdio.printStatus('Rolling new engine hash $engineRevision to framework checkout...');
|
||||
needsCommit = await framework.updateEngineRevision(engineRevision);
|
||||
if (needsCommit) {
|
||||
final String revision = await framework.commit(
|
||||
'Update Engine revision to $engineRevision for ${state.releaseChannel} release ${state.releaseVersion}',
|
||||
addFirst: true,
|
||||
'Update Engine revision to $engineRevision for ${state.releaseChannel} release ${state.releaseVersion}',
|
||||
addFirst: true,
|
||||
);
|
||||
// append to list of cherrypicks so we know a PR is required
|
||||
state.framework.cherrypicks.add(pb.Cherrypick.create()
|
||||
..appliedRevision = revision
|
||||
..state = pb.CherrypickState.COMPLETED
|
||||
state.framework.cherrypicks.add(
|
||||
pb.Cherrypick.create()
|
||||
..appliedRevision = revision
|
||||
..state = pb.CherrypickState.COMPLETED,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -202,21 +203,24 @@ class NextContext extends Context {
|
||||
|
||||
if (state.framework.cherrypicks.isEmpty) {
|
||||
stdio.printStatus(
|
||||
'This release has no framework cherrypicks. However, a framework PR is still\n'
|
||||
'required to roll engine cherrypicks.',
|
||||
'This release has no framework cherrypicks. However, a framework PR is still\n'
|
||||
'required to roll engine cherrypicks.',
|
||||
);
|
||||
} else if (unappliedCherrypicks.isEmpty) {
|
||||
stdio.printStatus('All framework cherrypicks were auto-applied by the conductor.');
|
||||
} else {
|
||||
if (unappliedCherrypicks.length == 1) {
|
||||
stdio.printStatus('There was ${unappliedCherrypicks.length} cherrypick that was not auto-applied.',);
|
||||
}
|
||||
else {
|
||||
stdio.printStatus('There were ${unappliedCherrypicks.length} cherrypicks that were not auto-applied.',);
|
||||
stdio.printStatus(
|
||||
'There was ${unappliedCherrypicks.length} cherrypick that was not auto-applied.',
|
||||
);
|
||||
} else {
|
||||
stdio.printStatus(
|
||||
'There were ${unappliedCherrypicks.length} cherrypicks that were not auto-applied.',
|
||||
);
|
||||
}
|
||||
stdio.printStatus(
|
||||
'These must be applied manually in the directory '
|
||||
'${state.framework.checkoutPath} before proceeding.\n',
|
||||
'These must be applied manually in the directory '
|
||||
'${state.framework.checkoutPath} before proceeding.\n',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,12 +252,13 @@ class NextContext extends Context {
|
||||
stdio.printStatus('to review the request\n\n$command');
|
||||
case pb.ReleasePhase.VERIFY_RELEASE:
|
||||
stdio.printStatus(
|
||||
'The current status of packaging builds can be seen at:\n'
|
||||
'\t$kLuciPackagingConsoleLink',
|
||||
'The current status of packaging builds can be seen at:\n'
|
||||
'\t$kLuciPackagingConsoleLink',
|
||||
);
|
||||
if (!autoAccept) {
|
||||
final bool response = await prompt(
|
||||
'Have all packaging builds finished successfully and post release announcements been completed?');
|
||||
'Have all packaging builds finished successfully and post release announcements been completed?',
|
||||
);
|
||||
if (!response) {
|
||||
stdio.printError('Aborting command.');
|
||||
updateState(state, stdio.logs);
|
||||
@@ -285,11 +290,11 @@ class NextContext extends Context {
|
||||
Future<void> pushWorkingBranch(Repository repository, pb.Repository pbRepository) async {
|
||||
try {
|
||||
await repository.pushRef(
|
||||
fromRef: 'HEAD',
|
||||
// Explicitly create new branch
|
||||
toRef: 'refs/heads/${pbRepository.workingBranch}',
|
||||
remote: pbRepository.mirror.name,
|
||||
force: force,
|
||||
fromRef: 'HEAD',
|
||||
// Explicitly create new branch
|
||||
toRef: 'refs/heads/${pbRepository.workingBranch}',
|
||||
remote: pbRepository.mirror.name,
|
||||
force: force,
|
||||
);
|
||||
} on GitException catch (exception) {
|
||||
if (exception.type == GitExceptionType.PushRejected && !force) {
|
||||
|
||||
@@ -64,18 +64,21 @@ This PR was generated by the automated
|
||||
///
|
||||
/// We never re-use a previous branch, so the branch name ends in an index
|
||||
/// number, which gets incremented for each roll.
|
||||
late final Future<String> featureBranchName = (() async {
|
||||
final List<String> remoteBranches = await framework.listRemoteBranches(framework.mirrorRemote!.name);
|
||||
late final Future<String> featureBranchName =
|
||||
(() async {
|
||||
final List<String> remoteBranches = await framework.listRemoteBranches(
|
||||
framework.mirrorRemote!.name,
|
||||
);
|
||||
|
||||
int x = 1;
|
||||
String name(int index) => 'packages-autoroller-branch-$index';
|
||||
int x = 1;
|
||||
String name(int index) => 'packages-autoroller-branch-$index';
|
||||
|
||||
while (remoteBranches.contains(name(x))) {
|
||||
x += 1;
|
||||
}
|
||||
while (remoteBranches.contains(name(x))) {
|
||||
x += 1;
|
||||
}
|
||||
|
||||
return name(x);
|
||||
})();
|
||||
return name(x);
|
||||
})();
|
||||
|
||||
void log(String message) {
|
||||
stdio.printStatus(_redactToken(message));
|
||||
@@ -94,7 +97,10 @@ This PR was generated by the automated
|
||||
return;
|
||||
}
|
||||
final Directory frameworkDir = await framework.checkoutDirectory;
|
||||
final String regenerateBinary = await _prebuildRegenerateGradleLockfilesBinary(frameworkDir, tempDir);
|
||||
final String regenerateBinary = await _prebuildRegenerateGradleLockfilesBinary(
|
||||
frameworkDir,
|
||||
tempDir,
|
||||
);
|
||||
final bool didUpdate = await updatePackages();
|
||||
if (!didUpdate) {
|
||||
log('Packages are already at latest.');
|
||||
@@ -122,9 +128,7 @@ This PR was generated by the automated
|
||||
/// Attempt to update all pub packages.
|
||||
///
|
||||
/// Will return whether or not any changes were made.
|
||||
Future<bool> updatePackages({
|
||||
bool verbose = true,
|
||||
}) async {
|
||||
Future<bool> updatePackages({bool verbose = true}) async {
|
||||
await framework.newBranch(await featureBranchName);
|
||||
final io.Process flutterProcess = await framework.streamFlutter(<String>[
|
||||
if (verbose) '--verbose',
|
||||
@@ -140,28 +144,21 @@ This PR was generated by the automated
|
||||
if (await framework.gitCheckoutClean()) {
|
||||
return false;
|
||||
}
|
||||
await framework.commit(
|
||||
'roll packages',
|
||||
addFirst: true,
|
||||
author: gitAuthor,
|
||||
);
|
||||
await framework.commit('roll packages', addFirst: true, author: gitAuthor);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<String> _prebuildRegenerateGradleLockfilesBinary(Directory repoRoot, Directory tempDir) async {
|
||||
Future<String> _prebuildRegenerateGradleLockfilesBinary(
|
||||
Directory repoRoot,
|
||||
Directory tempDir,
|
||||
) async {
|
||||
final String entrypoint = '${repoRoot.path}/dev/tools/bin/generate_gradle_lockfiles.dart';
|
||||
final File target = tempDir.childFile('generate_gradle_lockfiles');
|
||||
await framework.streamDart(
|
||||
<String>['pub', 'get'],
|
||||
workingDirectory: '${repoRoot.path}/dev/tools',
|
||||
);
|
||||
await framework.streamDart(<String>[
|
||||
'compile',
|
||||
'exe',
|
||||
entrypoint,
|
||||
'-o',
|
||||
target.path,
|
||||
]);
|
||||
'pub',
|
||||
'get',
|
||||
], workingDirectory: '${repoRoot.path}/dev/tools');
|
||||
await framework.streamDart(<String>['compile', 'exe', entrypoint, '-o', target.path]);
|
||||
|
||||
assert(
|
||||
target.existsSync(),
|
||||
@@ -174,33 +171,25 @@ This PR was generated by the automated
|
||||
}
|
||||
|
||||
Future<void> _regenerateGradleLockfiles(Directory repoRoot, String regenerateBinary) async {
|
||||
final List<String> cmd = <String>[
|
||||
regenerateBinary,
|
||||
'--no-gradle-generation',
|
||||
'--no-exclusion',
|
||||
];
|
||||
final List<String> cmd = <String>[regenerateBinary, '--no-gradle-generation', '--no-exclusion'];
|
||||
final io.Process regenerateProcess = await processManager.start(cmd);
|
||||
regenerateProcess
|
||||
.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) => stdio.printTrace('[stdout] $line'));
|
||||
regenerateProcess
|
||||
.stderr
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) => stdio.printTrace('[stderr] $line'));
|
||||
regenerateProcess.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) => stdio.printTrace('[stdout] $line'));
|
||||
regenerateProcess.stderr
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) => stdio.printTrace('[stderr] $line'));
|
||||
|
||||
final int exitCode = await regenerateProcess.exitCode;
|
||||
if (exitCode != 0) {
|
||||
throw io.ProcessException(
|
||||
cmd.first,
|
||||
cmd.sublist(1),
|
||||
'Process failed',
|
||||
exitCode,
|
||||
);
|
||||
throw io.ProcessException(cmd.first, cmd.sublist(1), 'Process failed', exitCode);
|
||||
}
|
||||
switch (CheckoutStatePostGradleRegeneration(await framework.gitStatus(), framework.fileSystem.path)) {
|
||||
switch (CheckoutStatePostGradleRegeneration(
|
||||
await framework.gitStatus(),
|
||||
framework.fileSystem.path,
|
||||
)) {
|
||||
// If the git checkout is clean, we did not update any lockfiles and we do
|
||||
// not need an additional commit.
|
||||
case NoDiff():
|
||||
@@ -208,11 +197,7 @@ This PR was generated by the automated
|
||||
return;
|
||||
case OnlyLockfileChanges():
|
||||
stdio.printTrace('Committing Gradle lockfile changes...');
|
||||
await framework.commit(
|
||||
'Re-generate Gradle lockfiles',
|
||||
addFirst: true,
|
||||
author: gitAuthor,
|
||||
);
|
||||
await framework.commit('Re-generate Gradle lockfiles', addFirst: true, author: gitAuthor);
|
||||
case NonLockfileChanges(changes: final List<String> changes):
|
||||
throw StateError(
|
||||
'Expected all diffs after re-generating gradle lockfiles to end in '
|
||||
@@ -235,25 +220,19 @@ This PR was generated by the automated
|
||||
}
|
||||
|
||||
Future<void> authLogout() {
|
||||
return cli(
|
||||
<String>['auth', 'logout', '--hostname', hostname],
|
||||
allowFailure: true,
|
||||
);
|
||||
return cli(<String>['auth', 'logout', '--hostname', hostname], allowFailure: true);
|
||||
}
|
||||
|
||||
Future<void> authLogin() {
|
||||
return cli(
|
||||
<String>[
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
hostname,
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
],
|
||||
stdin: '$token\n',
|
||||
);
|
||||
return cli(<String>[
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
hostname,
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
], stdin: '$token\n');
|
||||
}
|
||||
|
||||
static const String _prTitle = 'Roll pub packages';
|
||||
@@ -271,31 +250,24 @@ This PR was generated by the automated
|
||||
|
||||
// We will wrap title and body in double quotes before delegating to gh
|
||||
// binary
|
||||
await cli(
|
||||
<String>[
|
||||
'pr',
|
||||
'create',
|
||||
'--title',
|
||||
_prTitle,
|
||||
'--body',
|
||||
body.trim(),
|
||||
'--head',
|
||||
'$orgName:${await featureBranchName}',
|
||||
'--base',
|
||||
base,
|
||||
for (final String label in labels) ...<String>['--label', label],
|
||||
if (draft)
|
||||
'--draft',
|
||||
],
|
||||
workingDirectory: repository.path,
|
||||
);
|
||||
await cli(<String>[
|
||||
'pr',
|
||||
'create',
|
||||
'--title',
|
||||
_prTitle,
|
||||
'--body',
|
||||
body.trim(),
|
||||
'--head',
|
||||
'$orgName:${await featureBranchName}',
|
||||
'--base',
|
||||
base,
|
||||
for (final String label in labels) ...<String>['--label', label],
|
||||
if (draft) '--draft',
|
||||
], workingDirectory: repository.path);
|
||||
}
|
||||
|
||||
Future<void> help([List<String>? args]) {
|
||||
return cli(<String>[
|
||||
'help',
|
||||
...?args,
|
||||
]);
|
||||
return cli(<String>['help', ...?args]);
|
||||
}
|
||||
|
||||
/// Run a sub-process with the GitHub CLI client.
|
||||
@@ -327,17 +299,11 @@ This PR was generated by the automated
|
||||
await process.stdin.close();
|
||||
}
|
||||
final int exitCode = await process.exitCode;
|
||||
await Future.wait(<Future<Object?>>[
|
||||
stdoutFuture,
|
||||
stderrFuture,
|
||||
]);
|
||||
await Future.wait(<Future<Object?>>[stdoutFuture, stderrFuture]);
|
||||
final String stderr = stderrStrings.join();
|
||||
final String stdout = stdoutStrings.join();
|
||||
if (!allowFailure && exitCode != 0) {
|
||||
throw GitException(
|
||||
'$stderr\n$stdout',
|
||||
args,
|
||||
);
|
||||
throw GitException('$stderr\n$stdout', args);
|
||||
}
|
||||
log(stdout);
|
||||
return stdout;
|
||||
|
||||
@@ -25,13 +25,16 @@ export 'conductor_state.pbenum.dart';
|
||||
class Remote extends $pb.GeneratedMessage {
|
||||
factory Remote() => create();
|
||||
Remote._() : super();
|
||||
factory Remote.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Remote.fromBuffer($core.List<$core.int> i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromBuffer(i, r);
|
||||
factory Remote.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Remote.fromJson($core.String i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromJson(i, r);
|
||||
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Remote',
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'), createEmptyInstance: create)
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'),
|
||||
createEmptyInstance: create)
|
||||
..aOS(1, _omitFieldNames ? '' : 'name')
|
||||
..aOS(2, _omitFieldNames ? '' : 'url')
|
||||
..hasRequiredFields = false;
|
||||
@@ -43,7 +46,8 @@ class Remote extends $pb.GeneratedMessage {
|
||||
@$core.Deprecated('Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
Remote copyWith(void Function(Remote) updates) => super.copyWith((message) => updates(message as Remote)) as Remote;
|
||||
Remote copyWith(void Function(Remote) updates) =>
|
||||
super.copyWith((message) => updates(message as Remote)) as Remote;
|
||||
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
|
||||
@@ -52,7 +56,8 @@ class Remote extends $pb.GeneratedMessage {
|
||||
Remote createEmptyInstance() => create();
|
||||
static $pb.PbList<Remote> createRepeated() => $pb.PbList<Remote>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static Remote getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Remote>(create);
|
||||
static Remote getDefault() =>
|
||||
_defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Remote>(create);
|
||||
static Remote? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
@@ -83,17 +88,22 @@ class Remote extends $pb.GeneratedMessage {
|
||||
class Cherrypick extends $pb.GeneratedMessage {
|
||||
factory Cherrypick() => create();
|
||||
Cherrypick._() : super();
|
||||
factory Cherrypick.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Cherrypick.fromBuffer($core.List<$core.int> i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromBuffer(i, r);
|
||||
factory Cherrypick.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Cherrypick.fromJson($core.String i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromJson(i, r);
|
||||
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Cherrypick',
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'), createEmptyInstance: create)
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'),
|
||||
createEmptyInstance: create)
|
||||
..aOS(1, _omitFieldNames ? '' : 'trunkRevision', protoName: 'trunkRevision')
|
||||
..aOS(2, _omitFieldNames ? '' : 'appliedRevision', protoName: 'appliedRevision')
|
||||
..e<CherrypickState>(3, _omitFieldNames ? '' : 'state', $pb.PbFieldType.OE,
|
||||
defaultOrMaker: CherrypickState.PENDING, valueOf: CherrypickState.valueOf, enumValues: CherrypickState.values)
|
||||
defaultOrMaker: CherrypickState.PENDING,
|
||||
valueOf: CherrypickState.valueOf,
|
||||
enumValues: CherrypickState.values)
|
||||
..hasRequiredFields = false;
|
||||
|
||||
@$core.Deprecated('Using this can add significant overhead to your binary. '
|
||||
@@ -113,7 +123,8 @@ class Cherrypick extends $pb.GeneratedMessage {
|
||||
Cherrypick createEmptyInstance() => create();
|
||||
static $pb.PbList<Cherrypick> createRepeated() => $pb.PbList<Cherrypick>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static Cherrypick getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Cherrypick>(create);
|
||||
static Cherrypick getDefault() =>
|
||||
_defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Cherrypick>(create);
|
||||
static Cherrypick? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
@@ -156,20 +167,24 @@ class Cherrypick extends $pb.GeneratedMessage {
|
||||
class Repository extends $pb.GeneratedMessage {
|
||||
factory Repository() => create();
|
||||
Repository._() : super();
|
||||
factory Repository.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Repository.fromBuffer($core.List<$core.int> i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromBuffer(i, r);
|
||||
factory Repository.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory Repository.fromJson($core.String i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromJson(i, r);
|
||||
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Repository',
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'), createEmptyInstance: create)
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'),
|
||||
createEmptyInstance: create)
|
||||
..aOS(1, _omitFieldNames ? '' : 'candidateBranch', protoName: 'candidateBranch')
|
||||
..aOS(2, _omitFieldNames ? '' : 'startingGitHead', protoName: 'startingGitHead')
|
||||
..aOS(3, _omitFieldNames ? '' : 'currentGitHead', protoName: 'currentGitHead')
|
||||
..aOS(4, _omitFieldNames ? '' : 'checkoutPath', protoName: 'checkoutPath')
|
||||
..aOM<Remote>(5, _omitFieldNames ? '' : 'upstream', subBuilder: Remote.create)
|
||||
..aOM<Remote>(6, _omitFieldNames ? '' : 'mirror', subBuilder: Remote.create)
|
||||
..pc<Cherrypick>(7, _omitFieldNames ? '' : 'cherrypicks', $pb.PbFieldType.PM, subBuilder: Cherrypick.create)
|
||||
..pc<Cherrypick>(7, _omitFieldNames ? '' : 'cherrypicks', $pb.PbFieldType.PM,
|
||||
subBuilder: Cherrypick.create)
|
||||
..aOS(8, _omitFieldNames ? '' : 'dartRevision', protoName: 'dartRevision')
|
||||
..aOS(9, _omitFieldNames ? '' : 'workingBranch', protoName: 'workingBranch')
|
||||
..hasRequiredFields = false;
|
||||
@@ -191,7 +206,8 @@ class Repository extends $pb.GeneratedMessage {
|
||||
Repository createEmptyInstance() => create();
|
||||
static $pb.PbList<Repository> createRepeated() => $pb.PbList<Repository>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static Repository getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Repository>(create);
|
||||
static Repository getDefault() =>
|
||||
_defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Repository>(create);
|
||||
static Repository? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
@@ -301,13 +317,16 @@ class Repository extends $pb.GeneratedMessage {
|
||||
class ConductorState extends $pb.GeneratedMessage {
|
||||
factory ConductorState() => create();
|
||||
ConductorState._() : super();
|
||||
factory ConductorState.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory ConductorState.fromBuffer($core.List<$core.int> i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromBuffer(i, r);
|
||||
factory ConductorState.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
factory ConductorState.fromJson($core.String i,
|
||||
[$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
|
||||
create()..mergeFromJson(i, r);
|
||||
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ConductorState',
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'), createEmptyInstance: create)
|
||||
package: const $pb.PackageName(_omitMessageNames ? '' : 'conductor_state'),
|
||||
createEmptyInstance: create)
|
||||
..aOS(1, _omitFieldNames ? '' : 'releaseChannel', protoName: 'releaseChannel')
|
||||
..aOS(2, _omitFieldNames ? '' : 'releaseVersion', protoName: 'releaseVersion')
|
||||
..aOM<Repository>(4, _omitFieldNames ? '' : 'engine', subBuilder: Repository.create)
|
||||
@@ -345,7 +364,8 @@ class ConductorState extends $pb.GeneratedMessage {
|
||||
ConductorState createEmptyInstance() => create();
|
||||
static $pb.PbList<ConductorState> createRepeated() => $pb.PbList<ConductorState>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static ConductorState getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ConductorState>(create);
|
||||
static ConductorState getDefault() =>
|
||||
_defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ConductorState>(create);
|
||||
static ConductorState? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
|
||||
@@ -20,12 +20,16 @@ import 'package:protobuf/protobuf.dart' as $pb;
|
||||
class ReleasePhase extends $pb.ProtobufEnum {
|
||||
static const ReleasePhase APPLY_ENGINE_CHERRYPICKS =
|
||||
ReleasePhase._(0, _omitEnumNames ? '' : 'APPLY_ENGINE_CHERRYPICKS');
|
||||
static const ReleasePhase VERIFY_ENGINE_CI = ReleasePhase._(1, _omitEnumNames ? '' : 'VERIFY_ENGINE_CI');
|
||||
static const ReleasePhase VERIFY_ENGINE_CI =
|
||||
ReleasePhase._(1, _omitEnumNames ? '' : 'VERIFY_ENGINE_CI');
|
||||
static const ReleasePhase APPLY_FRAMEWORK_CHERRYPICKS =
|
||||
ReleasePhase._(2, _omitEnumNames ? '' : 'APPLY_FRAMEWORK_CHERRYPICKS');
|
||||
static const ReleasePhase PUBLISH_VERSION = ReleasePhase._(3, _omitEnumNames ? '' : 'PUBLISH_VERSION');
|
||||
static const ReleasePhase VERIFY_RELEASE = ReleasePhase._(5, _omitEnumNames ? '' : 'VERIFY_RELEASE');
|
||||
static const ReleasePhase RELEASE_COMPLETED = ReleasePhase._(6, _omitEnumNames ? '' : 'RELEASE_COMPLETED');
|
||||
static const ReleasePhase PUBLISH_VERSION =
|
||||
ReleasePhase._(3, _omitEnumNames ? '' : 'PUBLISH_VERSION');
|
||||
static const ReleasePhase VERIFY_RELEASE =
|
||||
ReleasePhase._(5, _omitEnumNames ? '' : 'VERIFY_RELEASE');
|
||||
static const ReleasePhase RELEASE_COMPLETED =
|
||||
ReleasePhase._(6, _omitEnumNames ? '' : 'RELEASE_COMPLETED');
|
||||
|
||||
static const $core.List<ReleasePhase> values = <ReleasePhase>[
|
||||
APPLY_ENGINE_CHERRYPICKS,
|
||||
@@ -56,14 +60,16 @@ class CherrypickState extends $pb.ProtobufEnum {
|
||||
ABANDONED,
|
||||
];
|
||||
|
||||
static final $core.Map<$core.int, CherrypickState> _byValue = $pb.ProtobufEnum.initByValue(values);
|
||||
static final $core.Map<$core.int, CherrypickState> _byValue =
|
||||
$pb.ProtobufEnum.initByValue(values);
|
||||
static CherrypickState? valueOf($core.int value) => _byValue[value];
|
||||
|
||||
const CherrypickState._($core.int v, $core.String n) : super(v, n);
|
||||
}
|
||||
|
||||
class ReleaseType extends $pb.ProtobufEnum {
|
||||
static const ReleaseType STABLE_INITIAL = ReleaseType._(0, _omitEnumNames ? '' : 'STABLE_INITIAL');
|
||||
static const ReleaseType STABLE_INITIAL =
|
||||
ReleaseType._(0, _omitEnumNames ? '' : 'STABLE_INITIAL');
|
||||
static const ReleaseType STABLE_HOTFIX = ReleaseType._(1, _omitEnumNames ? '' : 'STABLE_HOTFIX');
|
||||
static const ReleaseType BETA_INITIAL = ReleaseType._(2, _omitEnumNames ? '' : 'BETA_INITIAL');
|
||||
static const ReleaseType BETA_HOTFIX = ReleaseType._(3, _omitEnumNames ? '' : 'BETA_HOTFIX');
|
||||
|
||||
@@ -34,8 +34,8 @@ const ReleasePhase$json = {
|
||||
};
|
||||
|
||||
/// Descriptor for `ReleasePhase`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||
final $typed_data.Uint8List releasePhaseDescriptor =
|
||||
$convert.base64Decode('CgxSZWxlYXNlUGhhc2USHAoYQVBQTFlfRU5HSU5FX0NIRVJSWVBJQ0tTEAASFAoQVkVSSUZZX0'
|
||||
final $typed_data.Uint8List releasePhaseDescriptor = $convert
|
||||
.base64Decode('CgxSZWxlYXNlUGhhc2USHAoYQVBQTFlfRU5HSU5FX0NIRVJSWVBJQ0tTEAASFAoQVkVSSUZZX0'
|
||||
'VOR0lORV9DSRABEh8KG0FQUExZX0ZSQU1FV09SS19DSEVSUllQSUNLUxACEhMKD1BVQkxJU0hf'
|
||||
'VkVSU0lPThADEhIKDlZFUklGWV9SRUxFQVNFEAUSFQoRUkVMRUFTRV9DT01QTEVURUQQBiIECA'
|
||||
'QQBA==');
|
||||
@@ -52,8 +52,8 @@ const CherrypickState$json = {
|
||||
};
|
||||
|
||||
/// Descriptor for `CherrypickState`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||
final $typed_data.Uint8List cherrypickStateDescriptor =
|
||||
$convert.base64Decode('Cg9DaGVycnlwaWNrU3RhdGUSCwoHUEVORElORxAAEhkKFVBFTkRJTkdfV0lUSF9DT05GTElDVB'
|
||||
final $typed_data.Uint8List cherrypickStateDescriptor = $convert
|
||||
.base64Decode('Cg9DaGVycnlwaWNrU3RhdGUSCwoHUEVORElORxAAEhkKFVBFTkRJTkdfV0lUSF9DT05GTElDVB'
|
||||
'ABEg0KCUNPTVBMRVRFRBACEg0KCUFCQU5ET05FRBAD');
|
||||
|
||||
@$core.Deprecated('Use releaseTypeDescriptor instead')
|
||||
@@ -68,8 +68,8 @@ const ReleaseType$json = {
|
||||
};
|
||||
|
||||
/// Descriptor for `ReleaseType`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||
final $typed_data.Uint8List releaseTypeDescriptor =
|
||||
$convert.base64Decode('CgtSZWxlYXNlVHlwZRISCg5TVEFCTEVfSU5JVElBTBAAEhEKDVNUQUJMRV9IT1RGSVgQARIQCg'
|
||||
final $typed_data.Uint8List releaseTypeDescriptor = $convert
|
||||
.base64Decode('CgtSZWxlYXNlVHlwZRISCg5TVEFCTEVfSU5JVElBTBAAEhEKDVNUQUJMRV9IT1RGSVgQARIQCg'
|
||||
'xCRVRBX0lOSVRJQUwQAhIPCgtCRVRBX0hPVEZJWBAD');
|
||||
|
||||
@$core.Deprecated('Use remoteDescriptor instead')
|
||||
@@ -96,8 +96,8 @@ const Cherrypick$json = {
|
||||
};
|
||||
|
||||
/// Descriptor for `Cherrypick`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List cherrypickDescriptor =
|
||||
$convert.base64Decode('CgpDaGVycnlwaWNrEiQKDXRydW5rUmV2aXNpb24YASABKAlSDXRydW5rUmV2aXNpb24SKAoPYX'
|
||||
final $typed_data.Uint8List cherrypickDescriptor = $convert
|
||||
.base64Decode('CgpDaGVycnlwaWNrEiQKDXRydW5rUmV2aXNpb24YASABKAlSDXRydW5rUmV2aXNpb24SKAoPYX'
|
||||
'BwbGllZFJldmlzaW9uGAIgASgJUg9hcHBsaWVkUmV2aXNpb24SNgoFc3RhdGUYAyABKA4yIC5j'
|
||||
'b25kdWN0b3Jfc3RhdGUuQ2hlcnJ5cGlja1N0YXRlUgVzdGF0ZQ==');
|
||||
|
||||
@@ -111,15 +111,22 @@ const Repository$json = {
|
||||
{'1': 'checkoutPath', '3': 4, '4': 1, '5': 9, '10': 'checkoutPath'},
|
||||
{'1': 'upstream', '3': 5, '4': 1, '5': 11, '6': '.conductor_state.Remote', '10': 'upstream'},
|
||||
{'1': 'mirror', '3': 6, '4': 1, '5': 11, '6': '.conductor_state.Remote', '10': 'mirror'},
|
||||
{'1': 'cherrypicks', '3': 7, '4': 3, '5': 11, '6': '.conductor_state.Cherrypick', '10': 'cherrypicks'},
|
||||
{
|
||||
'1': 'cherrypicks',
|
||||
'3': 7,
|
||||
'4': 3,
|
||||
'5': 11,
|
||||
'6': '.conductor_state.Cherrypick',
|
||||
'10': 'cherrypicks'
|
||||
},
|
||||
{'1': 'dartRevision', '3': 8, '4': 1, '5': 9, '10': 'dartRevision'},
|
||||
{'1': 'workingBranch', '3': 9, '4': 1, '5': 9, '10': 'workingBranch'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `Repository`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List repositoryDescriptor =
|
||||
$convert.base64Decode('CgpSZXBvc2l0b3J5EigKD2NhbmRpZGF0ZUJyYW5jaBgBIAEoCVIPY2FuZGlkYXRlQnJhbmNoEi'
|
||||
final $typed_data.Uint8List repositoryDescriptor = $convert
|
||||
.base64Decode('CgpSZXBvc2l0b3J5EigKD2NhbmRpZGF0ZUJyYW5jaBgBIAEoCVIPY2FuZGlkYXRlQnJhbmNoEi'
|
||||
'gKD3N0YXJ0aW5nR2l0SGVhZBgCIAEoCVIPc3RhcnRpbmdHaXRIZWFkEiYKDmN1cnJlbnRHaXRI'
|
||||
'ZWFkGAMgASgJUg5jdXJyZW50R2l0SGVhZBIiCgxjaGVja291dFBhdGgYBCABKAlSDGNoZWNrb3'
|
||||
'V0UGF0aBIzCgh1cHN0cmVhbRgFIAEoCzIXLmNvbmR1Y3Rvcl9zdGF0ZS5SZW1vdGVSCHVwc3Ry'
|
||||
@@ -135,19 +142,40 @@ const ConductorState$json = {
|
||||
{'1': 'releaseChannel', '3': 1, '4': 1, '5': 9, '10': 'releaseChannel'},
|
||||
{'1': 'releaseVersion', '3': 2, '4': 1, '5': 9, '10': 'releaseVersion'},
|
||||
{'1': 'engine', '3': 4, '4': 1, '5': 11, '6': '.conductor_state.Repository', '10': 'engine'},
|
||||
{'1': 'framework', '3': 5, '4': 1, '5': 11, '6': '.conductor_state.Repository', '10': 'framework'},
|
||||
{
|
||||
'1': 'framework',
|
||||
'3': 5,
|
||||
'4': 1,
|
||||
'5': 11,
|
||||
'6': '.conductor_state.Repository',
|
||||
'10': 'framework'
|
||||
},
|
||||
{'1': 'createdDate', '3': 6, '4': 1, '5': 3, '10': 'createdDate'},
|
||||
{'1': 'lastUpdatedDate', '3': 7, '4': 1, '5': 3, '10': 'lastUpdatedDate'},
|
||||
{'1': 'logs', '3': 8, '4': 3, '5': 9, '10': 'logs'},
|
||||
{'1': 'currentPhase', '3': 9, '4': 1, '5': 14, '6': '.conductor_state.ReleasePhase', '10': 'currentPhase'},
|
||||
{
|
||||
'1': 'currentPhase',
|
||||
'3': 9,
|
||||
'4': 1,
|
||||
'5': 14,
|
||||
'6': '.conductor_state.ReleasePhase',
|
||||
'10': 'currentPhase'
|
||||
},
|
||||
{'1': 'conductorVersion', '3': 10, '4': 1, '5': 9, '10': 'conductorVersion'},
|
||||
{'1': 'releaseType', '3': 11, '4': 1, '5': 14, '6': '.conductor_state.ReleaseType', '10': 'releaseType'},
|
||||
{
|
||||
'1': 'releaseType',
|
||||
'3': 11,
|
||||
'4': 1,
|
||||
'5': 14,
|
||||
'6': '.conductor_state.ReleaseType',
|
||||
'10': 'releaseType'
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `ConductorState`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List conductorStateDescriptor =
|
||||
$convert.base64Decode('Cg5Db25kdWN0b3JTdGF0ZRImCg5yZWxlYXNlQ2hhbm5lbBgBIAEoCVIOcmVsZWFzZUNoYW5uZW'
|
||||
final $typed_data.Uint8List conductorStateDescriptor = $convert
|
||||
.base64Decode('Cg5Db25kdWN0b3JTdGF0ZRImCg5yZWxlYXNlQ2hhbm5lbBgBIAEoCVIOcmVsZWFzZUNoYW5uZW'
|
||||
'wSJgoOcmVsZWFzZVZlcnNpb24YAiABKAlSDnJlbGVhc2VWZXJzaW9uEjMKBmVuZ2luZRgEIAEo'
|
||||
'CzIbLmNvbmR1Y3Rvcl9zdGF0ZS5SZXBvc2l0b3J5UgZlbmdpbmUSOQoJZnJhbWV3b3JrGAUgAS'
|
||||
'gLMhsuY29uZHVjdG9yX3N0YXRlLlJlcG9zaXRvcnlSCWZyYW1ld29yaxIgCgtjcmVhdGVkRGF0'
|
||||
|
||||
@@ -17,14 +17,10 @@ import './stdio.dart';
|
||||
import './version.dart';
|
||||
|
||||
/// Allowed git remote names.
|
||||
enum RemoteName {
|
||||
upstream,
|
||||
mirror,
|
||||
}
|
||||
enum RemoteName { upstream, mirror }
|
||||
|
||||
class Remote {
|
||||
const Remote({required RemoteName name, required this.url})
|
||||
: _name = name, assert(url != '');
|
||||
const Remote({required RemoteName name, required this.url}) : _name = name, assert(url != '');
|
||||
|
||||
const Remote.mirror(String url) : this(name: RemoteName.mirror, url: url);
|
||||
const Remote.upstream(String url) : this(name: RemoteName.upstream, url: url);
|
||||
@@ -34,7 +30,7 @@ class Remote {
|
||||
/// The name of the remote.
|
||||
String get name => switch (_name) {
|
||||
RemoteName.upstream => 'upstream',
|
||||
RemoteName.mirror => 'mirror',
|
||||
RemoteName.mirror => 'mirror',
|
||||
};
|
||||
|
||||
/// The URL of the remote.
|
||||
@@ -89,8 +85,8 @@ abstract class Repository {
|
||||
this.localUpstream = false,
|
||||
this.previousCheckoutLocation,
|
||||
this.mirrorRemote,
|
||||
}) : git = Git(processManager),
|
||||
assert(upstreamRemote.url.isNotEmpty);
|
||||
}) : git = Git(processManager),
|
||||
assert(upstreamRemote.url.isNotEmpty);
|
||||
|
||||
final String name;
|
||||
final Remote upstreamRemote;
|
||||
@@ -135,7 +131,8 @@ abstract class Repository {
|
||||
_checkoutDirectory = fileSystem.directory(previousCheckoutLocation);
|
||||
if (!_checkoutDirectory!.existsSync()) {
|
||||
throw ConductorException(
|
||||
'Provided previousCheckoutLocation $previousCheckoutLocation does not exist on disk!');
|
||||
'Provided previousCheckoutLocation $previousCheckoutLocation does not exist on disk!',
|
||||
);
|
||||
}
|
||||
if (initialRef != null) {
|
||||
assert(initialRef != '');
|
||||
@@ -183,8 +180,7 @@ abstract class Repository {
|
||||
|
||||
return <String>[
|
||||
for (final String line in output.split('\n'))
|
||||
if (_lsRemotePattern.firstMatch(line) case final RegExpMatch match)
|
||||
match.group(1)!,
|
||||
if (_lsRemotePattern.firstMatch(line) case final RegExpMatch match) match.group(1)!,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -195,9 +191,7 @@ abstract class Repository {
|
||||
checkoutDirectory.deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
stdio.printTrace(
|
||||
'Cloning $name from ${upstreamRemote.url} to ${checkoutDirectory.path}...',
|
||||
);
|
||||
stdio.printTrace('Cloning $name from ${upstreamRemote.url} to ${checkoutDirectory.path}...');
|
||||
await git.run(
|
||||
<String>[
|
||||
'clone',
|
||||
@@ -242,9 +236,7 @@ abstract class Repository {
|
||||
);
|
||||
}
|
||||
final String revision = await reverseParse('HEAD');
|
||||
stdio.printTrace(
|
||||
'Repository $name is checked out at revision "$revision".',
|
||||
);
|
||||
stdio.printTrace('Repository $name is checked out at revision "$revision".');
|
||||
}
|
||||
|
||||
/// The URL of the remote named [remoteName].
|
||||
@@ -312,24 +304,13 @@ abstract class Repository {
|
||||
}
|
||||
|
||||
/// Obtain the version tag at the tip of a release branch.
|
||||
Future<String> getFullTag(
|
||||
String remoteName,
|
||||
String branchName, {
|
||||
bool exact = true,
|
||||
}) async {
|
||||
Future<String> getFullTag(String remoteName, String branchName, {bool exact = true}) async {
|
||||
// includes both stable (e.g. 1.2.3) and dev tags (e.g. 1.2.3-4.5.pre)
|
||||
const String glob = '*.*.*';
|
||||
// describe the latest dev release
|
||||
final String ref = 'refs/remotes/$remoteName/$branchName';
|
||||
return git.getOutput(
|
||||
<String>[
|
||||
'describe',
|
||||
'--match',
|
||||
glob,
|
||||
if (exact) '--exact-match',
|
||||
'--tags',
|
||||
ref,
|
||||
],
|
||||
<String>['describe', '--match', glob, if (exact) '--exact-match', '--tags', ref],
|
||||
'obtain last released version number',
|
||||
workingDirectory: (await checkoutDirectory).path,
|
||||
);
|
||||
@@ -358,11 +339,11 @@ abstract class Repository {
|
||||
|
||||
/// List commits in reverse chronological order.
|
||||
Future<List<String>> revList(List<String> args) async {
|
||||
return (await git.getOutput(<String>['rev-list', ...args],
|
||||
'rev-list with args ${args.join(' ')}',
|
||||
workingDirectory: (await checkoutDirectory).path))
|
||||
.trim()
|
||||
.split('\n');
|
||||
return (await git.getOutput(
|
||||
<String>['rev-list', ...args],
|
||||
'rev-list with args ${args.join(' ')}',
|
||||
workingDirectory: (await checkoutDirectory).path,
|
||||
)).trim().split('\n');
|
||||
}
|
||||
|
||||
/// Look up the commit for [ref].
|
||||
@@ -379,12 +360,7 @@ abstract class Repository {
|
||||
/// Determines if one ref is an ancestor for another.
|
||||
Future<bool> isAncestor(String possibleAncestor, String possibleDescendant) async {
|
||||
final io.ProcessResult result = await git.run(
|
||||
<String>[
|
||||
'merge-base',
|
||||
'--is-ancestor',
|
||||
possibleDescendant,
|
||||
possibleAncestor,
|
||||
],
|
||||
<String>['merge-base', '--is-ancestor', possibleDescendant, possibleAncestor],
|
||||
'verify $possibleAncestor is a direct ancestor of $possibleDescendant.',
|
||||
allowNonZeroExitCode: true,
|
||||
workingDirectory: (await checkoutDirectory).path,
|
||||
@@ -420,16 +396,8 @@ abstract class Repository {
|
||||
bool force = false,
|
||||
bool dryRun = false,
|
||||
}) async {
|
||||
final List<String> args = <String>[
|
||||
'push',
|
||||
if (force) '--force',
|
||||
remote,
|
||||
'$fromRef:$toRef',
|
||||
];
|
||||
final String command = <String>[
|
||||
'git',
|
||||
...args,
|
||||
].join(' ');
|
||||
final List<String> args = <String>['push', if (force) '--force', remote, '$fromRef:$toRef'];
|
||||
final String command = <String>['git', ...args].join(' ');
|
||||
if (dryRun) {
|
||||
stdio.printStatus('About to execute command: `$command`');
|
||||
} else {
|
||||
@@ -442,19 +410,15 @@ abstract class Repository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> commit(
|
||||
String message, {
|
||||
bool addFirst = false,
|
||||
String? author,
|
||||
}) async {
|
||||
final bool hasChanges = (await git.getOutput(
|
||||
<String>['status', '--porcelain'],
|
||||
'check for uncommitted changes',
|
||||
workingDirectory: (await checkoutDirectory).path,
|
||||
)).trim().isNotEmpty;
|
||||
Future<String> commit(String message, {bool addFirst = false, String? author}) async {
|
||||
final bool hasChanges =
|
||||
(await git.getOutput(
|
||||
<String>['status', '--porcelain'],
|
||||
'check for uncommitted changes',
|
||||
workingDirectory: (await checkoutDirectory).path,
|
||||
)).trim().isNotEmpty;
|
||||
if (!hasChanges) {
|
||||
throw ConductorException(
|
||||
'Tried to commit with message $message but no changes were present');
|
||||
throw ConductorException('Tried to commit with message $message but no changes were present');
|
||||
}
|
||||
if (addFirst) {
|
||||
await git.run(
|
||||
@@ -466,15 +430,11 @@ abstract class Repository {
|
||||
String? authorArg;
|
||||
if (author != null) {
|
||||
if (author.contains('"')) {
|
||||
throw FormatException(
|
||||
'Commit author cannot contain character \'"\', received $author',
|
||||
);
|
||||
throw FormatException('Commit author cannot contain character \'"\', received $author');
|
||||
}
|
||||
// verify [author] matches git author convention, e.g. "Jane Doe <jane.doe@email.com>"
|
||||
if (!RegExp(r'.+<.*>').hasMatch(author)) {
|
||||
throw FormatException(
|
||||
'Commit author appears malformed: "$author"',
|
||||
);
|
||||
throw FormatException('Commit author appears malformed: "$author"');
|
||||
}
|
||||
authorArg = '--author="$author"';
|
||||
}
|
||||
@@ -543,16 +503,13 @@ class FrameworkRepository extends Repository {
|
||||
super.mirrorRemote,
|
||||
List<String>? additionalRequiredLocalBranches,
|
||||
}) : super(
|
||||
fileSystem: checkouts.fileSystem,
|
||||
parentDirectory: checkouts.directory,
|
||||
platform: checkouts.platform,
|
||||
processManager: checkouts.processManager,
|
||||
stdio: checkouts.stdio,
|
||||
requiredLocalBranches: <String>[
|
||||
...?additionalRequiredLocalBranches,
|
||||
...kReleaseChannels,
|
||||
],
|
||||
);
|
||||
fileSystem: checkouts.fileSystem,
|
||||
parentDirectory: checkouts.directory,
|
||||
platform: checkouts.platform,
|
||||
processManager: checkouts.processManager,
|
||||
stdio: checkouts.stdio,
|
||||
requiredLocalBranches: <String>[...?additionalRequiredLocalBranches, ...kReleaseChannels],
|
||||
);
|
||||
|
||||
/// A [FrameworkRepository] with the host conductor's repo set as upstream.
|
||||
///
|
||||
@@ -579,11 +536,7 @@ class FrameworkRepository extends Repository {
|
||||
static const String defaultBranch = 'master';
|
||||
|
||||
Future<String> get cacheDirectory async {
|
||||
return fileSystem.path.join(
|
||||
(await checkoutDirectory).path,
|
||||
'bin',
|
||||
'cache',
|
||||
);
|
||||
return fileSystem.path.join((await checkoutDirectory).path, 'bin', 'cache');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -620,28 +573,19 @@ class FrameworkRepository extends Repository {
|
||||
Future<io.ProcessResult> runFlutter(List<String> args) async {
|
||||
await _ensureToolReady();
|
||||
final String workingDirectory = (await checkoutDirectory).path;
|
||||
return processManager.run(
|
||||
<String>[
|
||||
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
|
||||
...args,
|
||||
],
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
return processManager.run(<String>[
|
||||
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
|
||||
...args,
|
||||
], workingDirectory: workingDirectory);
|
||||
}
|
||||
|
||||
Future<void> streamDart(
|
||||
List<String> args, {
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
Future<void> streamDart(List<String> args, {String? workingDirectory}) async {
|
||||
final String repoWorkingDirectory = (await checkoutDirectory).path;
|
||||
|
||||
await _streamProcess(
|
||||
<String>[
|
||||
fileSystem.path.join(repoWorkingDirectory, 'bin', 'dart'),
|
||||
...args,
|
||||
],
|
||||
workingDirectory: workingDirectory ?? repoWorkingDirectory,
|
||||
);
|
||||
await _streamProcess(<String>[
|
||||
fileSystem.path.join(repoWorkingDirectory, 'bin', 'dart'),
|
||||
...args,
|
||||
], workingDirectory: workingDirectory ?? repoWorkingDirectory);
|
||||
}
|
||||
|
||||
Future<io.Process> streamFlutter(
|
||||
@@ -651,13 +595,10 @@ class FrameworkRepository extends Repository {
|
||||
}) async {
|
||||
final String workingDirectory = (await checkoutDirectory).path;
|
||||
|
||||
return _streamProcess(
|
||||
<String>[
|
||||
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
|
||||
...args,
|
||||
],
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
return _streamProcess(<String>[
|
||||
fileSystem.path.join(workingDirectory, 'bin', 'flutter'),
|
||||
...args,
|
||||
], workingDirectory: workingDirectory);
|
||||
}
|
||||
|
||||
Future<io.Process> _streamProcess(
|
||||
@@ -667,35 +608,22 @@ class FrameworkRepository extends Repository {
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
stdio.printTrace('Executing $cmd...');
|
||||
final io.Process process = await processManager.start(
|
||||
cmd,
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
final StreamSubscription<String> stdoutSub = process
|
||||
.stdout
|
||||
final io.Process process = await processManager.start(cmd, workingDirectory: workingDirectory);
|
||||
final StreamSubscription<String> stdoutSub = process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen(stdoutCallback ?? stdio.printTrace);
|
||||
final StreamSubscription<String> stderrSub = process
|
||||
.stderr
|
||||
final StreamSubscription<String> stderrSub = process.stderr
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen(stderrCallback ?? stdio.printError);
|
||||
await Future.wait<void>(<Future<void>>[
|
||||
stdoutSub.asFuture<void>(),
|
||||
stderrSub.asFuture<void>(),
|
||||
]);
|
||||
await Future.wait<void>(<Future<void>>[stdoutSub.asFuture<void>(), stderrSub.asFuture<void>()]);
|
||||
unawaited(stdoutSub.cancel());
|
||||
unawaited(stderrSub.cancel());
|
||||
|
||||
final int exitCode = await process.exitCode;
|
||||
if (exitCode != 0) {
|
||||
throw io.ProcessException(
|
||||
cmd.first,
|
||||
cmd.sublist(1),
|
||||
'Process failed',
|
||||
exitCode,
|
||||
);
|
||||
throw io.ProcessException(cmd.first, cmd.sublist(1), 'Process failed', exitCode);
|
||||
}
|
||||
return process;
|
||||
}
|
||||
@@ -716,11 +644,9 @@ class FrameworkRepository extends Repository {
|
||||
|
||||
Future<Version> flutterVersion() async {
|
||||
// Check version
|
||||
final io.ProcessResult result =
|
||||
await runFlutter(<String>['--version', '--machine']);
|
||||
final Map<String, dynamic> versionJson = jsonDecode(
|
||||
stdoutToString(result.stdout),
|
||||
) as Map<String, dynamic>;
|
||||
final io.ProcessResult result = await runFlutter(<String>['--version', '--machine']);
|
||||
final Map<String, dynamic> versionJson =
|
||||
jsonDecode(stdoutToString(result.stdout)) as Map<String, dynamic>;
|
||||
return Version.fromString(versionJson['frameworkVersion'] as String);
|
||||
}
|
||||
|
||||
@@ -797,11 +723,11 @@ class HostFrameworkRepository extends FrameworkRepository {
|
||||
String name = 'host-framework',
|
||||
required String upstreamPath,
|
||||
}) : super(
|
||||
checkouts,
|
||||
name: name,
|
||||
upstreamRemote: Remote.upstream('file://$upstreamPath/'),
|
||||
localUpstream: false,
|
||||
) {
|
||||
checkouts,
|
||||
name: name,
|
||||
upstreamRemote: Remote.upstream('file://$upstreamPath/'),
|
||||
localUpstream: false,
|
||||
) {
|
||||
_checkoutDirectory = checkouts.fileSystem.directory(upstreamPath);
|
||||
}
|
||||
|
||||
@@ -810,14 +736,12 @@ class HostFrameworkRepository extends FrameworkRepository {
|
||||
|
||||
@override
|
||||
Future<void> newBranch(String branchName) async {
|
||||
throw ConductorException(
|
||||
'newBranch not implemented for the host repository');
|
||||
throw ConductorException('newBranch not implemented for the host repository');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> checkout(String ref) async {
|
||||
throw ConductorException(
|
||||
'checkout not implemented for the host repository');
|
||||
throw ConductorException('checkout not implemented for the host repository');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -837,15 +761,12 @@ class HostFrameworkRepository extends FrameworkRepository {
|
||||
bool force = false,
|
||||
bool dryRun = false,
|
||||
}) {
|
||||
throw ConductorException(
|
||||
'updateChannel not implemented for the host repository');
|
||||
throw ConductorException('updateChannel not implemented for the host repository');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> authorEmptyCommit([String message = 'An empty commit']) async {
|
||||
throw ConductorException(
|
||||
'authorEmptyCommit not implemented for the host repository',
|
||||
);
|
||||
throw ConductorException('authorEmptyCommit not implemented for the host repository');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,13 +781,13 @@ class EngineRepository extends Repository {
|
||||
super.mirrorRemote,
|
||||
List<String>? additionalRequiredLocalBranches,
|
||||
}) : super(
|
||||
fileSystem: checkouts.fileSystem,
|
||||
parentDirectory: checkouts.directory,
|
||||
platform: checkouts.platform,
|
||||
processManager: checkouts.processManager,
|
||||
stdio: checkouts.stdio,
|
||||
requiredLocalBranches: additionalRequiredLocalBranches ?? const <String>[],
|
||||
);
|
||||
fileSystem: checkouts.fileSystem,
|
||||
parentDirectory: checkouts.directory,
|
||||
platform: checkouts.platform,
|
||||
processManager: checkouts.processManager,
|
||||
stdio: checkouts.stdio,
|
||||
requiredLocalBranches: additionalRequiredLocalBranches ?? const <String>[],
|
||||
);
|
||||
|
||||
final Checkouts checkouts;
|
||||
|
||||
@@ -874,21 +795,18 @@ class EngineRepository extends Repository {
|
||||
static const String defaultBranch = 'main';
|
||||
|
||||
/// Update the `dart_revision` entry in the DEPS file.
|
||||
Future<void> updateDartRevision(
|
||||
String newRevision, {
|
||||
@visibleForTesting File? depsFile,
|
||||
}) async {
|
||||
Future<void> updateDartRevision(String newRevision, {@visibleForTesting File? depsFile}) async {
|
||||
assert(newRevision.length == 40);
|
||||
depsFile ??= (await checkoutDirectory).childFile('DEPS');
|
||||
final String fileContent = depsFile.readAsStringSync();
|
||||
final RegExp dartPattern = RegExp("[ ]+'dart_revision': '([a-z0-9]{40})',");
|
||||
final Iterable<RegExpMatch> allMatches =
|
||||
dartPattern.allMatches(fileContent);
|
||||
final Iterable<RegExpMatch> allMatches = dartPattern.allMatches(fileContent);
|
||||
if (allMatches.length != 1) {
|
||||
throw ConductorException(
|
||||
'Unexpected content in the DEPS file at ${depsFile.path}\n'
|
||||
'Expected to find pattern ${dartPattern.pattern} 1 times, but got '
|
||||
'${allMatches.length}.');
|
||||
'Unexpected content in the DEPS file at ${depsFile.path}\n'
|
||||
'Expected to find pattern ${dartPattern.pattern} 1 times, but got '
|
||||
'${allMatches.length}.',
|
||||
);
|
||||
}
|
||||
final String updatedFileContent = fileContent.replaceFirst(
|
||||
dartPattern,
|
||||
@@ -911,10 +829,7 @@ class EngineRepository extends Repository {
|
||||
}
|
||||
|
||||
/// An enum of all the repositories that the Conductor supports.
|
||||
enum RepositoryType {
|
||||
framework,
|
||||
engine,
|
||||
}
|
||||
enum RepositoryType { framework, engine }
|
||||
|
||||
class Checkouts {
|
||||
Checkouts({
|
||||
|
||||
@@ -43,13 +43,11 @@ const String kGithubUsernameOption = 'github-username';
|
||||
/// in which configuration is provided by editing a bash script that sets environment
|
||||
/// variables and then invokes the conductor tool.
|
||||
class StartCommand extends Command<void> {
|
||||
StartCommand({
|
||||
required this.checkouts,
|
||||
required this.conductorVersion,
|
||||
}) : platform = checkouts.platform,
|
||||
processManager = checkouts.processManager,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
StartCommand({required this.checkouts, required this.conductorVersion})
|
||||
: platform = checkouts.platform,
|
||||
processManager = checkouts.processManager,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
final String defaultPath = state_import.defaultStateFilePath(platform);
|
||||
argParser.addOption(
|
||||
kCandidateOption,
|
||||
@@ -60,16 +58,11 @@ class StartCommand extends Command<void> {
|
||||
help: 'The target release channel for the release.',
|
||||
allowed: kBaseReleaseChannels,
|
||||
);
|
||||
argParser.addOption(
|
||||
kFrameworkMirrorOption,
|
||||
help:
|
||||
'Configurable Framework repo mirror remote.',
|
||||
);
|
||||
argParser.addOption(kFrameworkMirrorOption, help: 'Configurable Framework repo mirror remote.');
|
||||
argParser.addOption(
|
||||
kFrameworkUpstreamOption,
|
||||
defaultsTo: FrameworkRepository.defaultUpstream,
|
||||
help:
|
||||
'Configurable Framework repo upstream remote. Primarily for testing.',
|
||||
help: 'Configurable Framework repo upstream remote. Primarily for testing.',
|
||||
hide: true,
|
||||
);
|
||||
argParser.addOption(
|
||||
@@ -83,10 +76,7 @@ class StartCommand extends Command<void> {
|
||||
defaultsTo: defaultPath,
|
||||
help: 'Path to persistent state file. Defaults to $defaultPath',
|
||||
);
|
||||
argParser.addOption(
|
||||
kDartRevisionOption,
|
||||
help: 'New Dart revision to cherrypick.',
|
||||
);
|
||||
argParser.addOption(kDartRevisionOption, help: 'New Dart revision to cherrypick.');
|
||||
argParser.addFlag(
|
||||
kForceFlag,
|
||||
abbr: 'f',
|
||||
@@ -94,13 +84,11 @@ class StartCommand extends Command<void> {
|
||||
);
|
||||
argParser.addOption(
|
||||
kVersionOverrideOption,
|
||||
help: 'Explicitly set the desired version. This should only be used if '
|
||||
help:
|
||||
'Explicitly set the desired version. This should only be used if '
|
||||
'the version computed by the tool is not correct.',
|
||||
);
|
||||
argParser.addOption(
|
||||
kGithubUsernameOption,
|
||||
help: 'Github username',
|
||||
);
|
||||
argParser.addOption(kGithubUsernameOption, help: 'Github username');
|
||||
}
|
||||
|
||||
final Checkouts checkouts;
|
||||
@@ -119,54 +107,34 @@ class StartCommand extends Command<void> {
|
||||
|
||||
@visibleForTesting
|
||||
StartContext createContext(ArgResults argumentResults) {
|
||||
|
||||
final String frameworkUpstream = getValueFromEnvOrArgs(
|
||||
kFrameworkUpstreamOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
)!;
|
||||
final String githubUsername = getValueFromEnvOrArgs(
|
||||
kGithubUsernameOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
)!;
|
||||
final String frameworkMirror = getValueFromEnvOrArgs(
|
||||
final String frameworkUpstream =
|
||||
getValueFromEnvOrArgs(kFrameworkUpstreamOption, argumentResults, platform.environment)!;
|
||||
final String githubUsername =
|
||||
getValueFromEnvOrArgs(kGithubUsernameOption, argumentResults, platform.environment)!;
|
||||
final String frameworkMirror =
|
||||
getValueFromEnvOrArgs(
|
||||
kFrameworkMirrorOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
allowNull: true,
|
||||
) ??
|
||||
'git@github.com:$githubUsername/flutter.git';
|
||||
final String engineUpstream = getValueFromEnvOrArgs(
|
||||
kEngineUpstreamOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
)!;
|
||||
final String engineUpstream =
|
||||
getValueFromEnvOrArgs(kEngineUpstreamOption, argumentResults, platform.environment)!;
|
||||
final String engineMirror = 'git@github.com:$githubUsername/engine.git';
|
||||
final String candidateBranch = getValueFromEnvOrArgs(
|
||||
kCandidateOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
)!;
|
||||
final String releaseChannel = getValueFromEnvOrArgs(
|
||||
kReleaseOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
)!;
|
||||
final String candidateBranch =
|
||||
getValueFromEnvOrArgs(kCandidateOption, argumentResults, platform.environment)!;
|
||||
final String releaseChannel =
|
||||
getValueFromEnvOrArgs(kReleaseOption, argumentResults, platform.environment)!;
|
||||
final String? dartRevision = getValueFromEnvOrArgs(
|
||||
kDartRevisionOption,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
allowNull: true,
|
||||
);
|
||||
final bool force = getBoolFromEnvOrArgs(
|
||||
kForceFlag,
|
||||
argumentResults,
|
||||
platform.environment,
|
||||
);
|
||||
final bool force = getBoolFromEnvOrArgs(kForceFlag, argumentResults, platform.environment);
|
||||
final File stateFile = checkouts.fileSystem.file(
|
||||
getValueFromEnvOrArgs(
|
||||
kStateOption, argumentResults, platform.environment),
|
||||
getValueFromEnvOrArgs(kStateOption, argumentResults, platform.environment),
|
||||
);
|
||||
final String? versionOverrideString = getValueFromEnvOrArgs(
|
||||
kVersionOverrideOption,
|
||||
@@ -201,9 +169,7 @@ class StartCommand extends Command<void> {
|
||||
Future<void> run() async {
|
||||
final ArgResults argumentResults = argResults!;
|
||||
if (!platform.isMacOS && !platform.isLinux) {
|
||||
throw ConductorException(
|
||||
'Error! This tool is only supported on macOS and Linux',
|
||||
);
|
||||
throw ConductorException('Error! This tool is only supported on macOS and Linux');
|
||||
}
|
||||
|
||||
return createContext(argumentResults).run();
|
||||
@@ -229,19 +195,19 @@ class StartContext extends Context {
|
||||
required super.stateFile,
|
||||
this.force = false,
|
||||
this.versionOverride,
|
||||
}) : git = Git(processManager),
|
||||
engine = EngineRepository(
|
||||
checkouts,
|
||||
initialRef: 'upstream/$candidateBranch',
|
||||
upstreamRemote: Remote.upstream(engineUpstream),
|
||||
mirrorRemote: Remote.mirror(engineMirror),
|
||||
),
|
||||
framework = FrameworkRepository(
|
||||
checkouts,
|
||||
initialRef: 'upstream/$candidateBranch',
|
||||
upstreamRemote: Remote.upstream(frameworkUpstream),
|
||||
mirrorRemote: Remote.mirror(frameworkMirror),
|
||||
);
|
||||
}) : git = Git(processManager),
|
||||
engine = EngineRepository(
|
||||
checkouts,
|
||||
initialRef: 'upstream/$candidateBranch',
|
||||
upstreamRemote: Remote.upstream(engineUpstream),
|
||||
mirrorRemote: Remote.mirror(engineMirror),
|
||||
),
|
||||
framework = FrameworkRepository(
|
||||
checkouts,
|
||||
initialRef: 'upstream/$candidateBranch',
|
||||
upstreamRemote: Remote.upstream(frameworkUpstream),
|
||||
mirrorRemote: Remote.mirror(frameworkMirror),
|
||||
);
|
||||
|
||||
final String candidateBranch;
|
||||
final String? dartRevision;
|
||||
@@ -276,15 +242,17 @@ class StartContext extends Context {
|
||||
|
||||
return switch (lastVersion.type) {
|
||||
VersionType.stable => ReleaseType.STABLE_HOTFIX,
|
||||
VersionType.development || VersionType.gitDescribe || VersionType.latest => ReleaseType.STABLE_INITIAL,
|
||||
VersionType.development || VersionType.gitDescribe || VersionType.latest =>
|
||||
ReleaseType.STABLE_INITIAL,
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> run() async {
|
||||
if (stateFile.existsSync()) {
|
||||
throw ConductorException(
|
||||
'Error! A persistent state file already found at ${stateFile.path}.\n\n'
|
||||
'Run `conductor clean` to cancel a previous release.');
|
||||
'Error! A persistent state file already found at ${stateFile.path}.\n\n'
|
||||
'Run `conductor clean` to cancel a previous release.',
|
||||
);
|
||||
}
|
||||
if (!releaseCandidateBranchRegex.hasMatch(candidateBranch)) {
|
||||
throw ConductorException(
|
||||
@@ -311,21 +279,21 @@ class StartContext extends Context {
|
||||
}
|
||||
|
||||
final String engineHead = await engine.reverseParse('HEAD');
|
||||
state.engine = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..workingBranch = workingBranchName
|
||||
..startingGitHead = engineHead
|
||||
..currentGitHead = engineHead
|
||||
..checkoutPath = (await engine.checkoutDirectory).path
|
||||
..upstream = (pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = engine.upstreamRemote.url
|
||||
)
|
||||
..mirror = (pb.Remote.create()
|
||||
..name = 'mirror'
|
||||
..url = engine.mirrorRemote!.url
|
||||
)
|
||||
);
|
||||
state.engine =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..workingBranch = workingBranchName
|
||||
..startingGitHead = engineHead
|
||||
..currentGitHead = engineHead
|
||||
..checkoutPath = (await engine.checkoutDirectory).path
|
||||
..upstream =
|
||||
(pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = engine.upstreamRemote.url)
|
||||
..mirror =
|
||||
(pb.Remote.create()
|
||||
..name = 'mirror'
|
||||
..url = engine.mirrorRemote!.url));
|
||||
if (dartRevision != null && dartRevision!.isNotEmpty) {
|
||||
state.engine.dartRevision = dartRevision!;
|
||||
}
|
||||
@@ -333,11 +301,9 @@ class StartContext extends Context {
|
||||
await framework.newBranch(workingBranchName);
|
||||
|
||||
// Get framework version
|
||||
final Version lastVersion = Version.fromString(await framework.getFullTag(
|
||||
framework.upstreamRemote.name,
|
||||
candidateBranch,
|
||||
exact: false,
|
||||
));
|
||||
final Version lastVersion = Version.fromString(
|
||||
await framework.getFullTag(framework.upstreamRemote.name, candidateBranch, exact: false),
|
||||
);
|
||||
|
||||
final String frameworkHead = await framework.reverseParse('HEAD');
|
||||
final String branchPoint = await framework.branchPoint(
|
||||
@@ -346,8 +312,7 @@ class StartContext extends Context {
|
||||
);
|
||||
final bool atBranchPoint = branchPoint == frameworkHead;
|
||||
|
||||
final ReleaseType releaseType =
|
||||
computeReleaseType(lastVersion, atBranchPoint);
|
||||
final ReleaseType releaseType = computeReleaseType(lastVersion, atBranchPoint);
|
||||
state.releaseType = releaseType;
|
||||
|
||||
try {
|
||||
@@ -371,21 +336,21 @@ class StartContext extends Context {
|
||||
|
||||
state.releaseVersion = nextVersion.toString();
|
||||
|
||||
state.framework = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..workingBranch = workingBranchName
|
||||
..startingGitHead = frameworkHead
|
||||
..currentGitHead = frameworkHead
|
||||
..checkoutPath = (await framework.checkoutDirectory).path
|
||||
..upstream = (pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = framework.upstreamRemote.url
|
||||
)
|
||||
..mirror = (pb.Remote.create()
|
||||
..name = 'mirror'
|
||||
..url = framework.mirrorRemote!.url
|
||||
)
|
||||
);
|
||||
state.framework =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..workingBranch = workingBranchName
|
||||
..startingGitHead = frameworkHead
|
||||
..currentGitHead = frameworkHead
|
||||
..checkoutPath = (await framework.checkoutDirectory).path
|
||||
..upstream =
|
||||
(pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = framework.upstreamRemote.url)
|
||||
..mirror =
|
||||
(pb.Remote.create()
|
||||
..name = 'mirror'
|
||||
..url = framework.mirrorRemote!.url));
|
||||
|
||||
state.currentPhase = ReleasePhase.APPLY_ENGINE_CHERRYPICKS;
|
||||
|
||||
@@ -401,9 +366,14 @@ class StartContext extends Context {
|
||||
/// Determine this release's version number from the [lastVersion] and the [incrementLetter].
|
||||
Version calculateNextVersion(Version lastVersion, ReleaseType releaseType) {
|
||||
return switch (releaseType) {
|
||||
ReleaseType.STABLE_INITIAL => Version(x: lastVersion.x, y: lastVersion.y, z: 0, type: VersionType.stable),
|
||||
ReleaseType.STABLE_HOTFIX => Version.increment(lastVersion, 'z'),
|
||||
ReleaseType.BETA_INITIAL => Version.fromCandidateBranch(candidateBranch),
|
||||
ReleaseType.STABLE_INITIAL => Version(
|
||||
x: lastVersion.x,
|
||||
y: lastVersion.y,
|
||||
z: 0,
|
||||
type: VersionType.stable,
|
||||
),
|
||||
ReleaseType.STABLE_HOTFIX => Version.increment(lastVersion, 'z'),
|
||||
ReleaseType.BETA_INITIAL => Version.fromCandidateBranch(candidateBranch),
|
||||
ReleaseType.BETA_HOTFIX || _ => Version.increment(lastVersion, 'n'),
|
||||
};
|
||||
}
|
||||
@@ -439,14 +409,9 @@ class StartContext extends Context {
|
||||
throw ConductorException('Aborting command.');
|
||||
}
|
||||
|
||||
stdio.printStatus(
|
||||
'Applying the tag $requestedVersion at the branch point $branchPoint');
|
||||
stdio.printStatus('Applying the tag $requestedVersion at the branch point $branchPoint');
|
||||
|
||||
await framework.tag(
|
||||
branchPoint,
|
||||
requestedVersion.toString(),
|
||||
frameworkUpstream,
|
||||
);
|
||||
await framework.tag(branchPoint, requestedVersion.toString(), frameworkUpstream);
|
||||
final Version nextVersion = Version.increment(requestedVersion, 'n');
|
||||
stdio.printStatus('The actual release will be version $nextVersion.');
|
||||
return nextVersion;
|
||||
|
||||
@@ -65,13 +65,9 @@ String luciConsoleLink(String candidateBranch, String repoName) {
|
||||
String defaultStateFilePath(Platform platform) {
|
||||
final String? home = platform.environment['HOME'];
|
||||
if (home == null) {
|
||||
throw globals.ConductorException(
|
||||
r'Environment variable $HOME must be set!');
|
||||
throw globals.ConductorException(r'Environment variable $HOME must be set!');
|
||||
}
|
||||
return <String>[
|
||||
home,
|
||||
kStateFileName,
|
||||
].join(platform.pathSeparator);
|
||||
return <String>[home, kStateFileName].join(platform.pathSeparator);
|
||||
}
|
||||
|
||||
String presentState(pb.ConductorState state) {
|
||||
@@ -81,9 +77,11 @@ String presentState(pb.ConductorState state) {
|
||||
buffer.writeln('Release version: ${state.releaseVersion}');
|
||||
buffer.writeln();
|
||||
buffer.writeln(
|
||||
'Release started at: ${DateTime.fromMillisecondsSinceEpoch(state.createdDate.toInt())}');
|
||||
'Release started at: ${DateTime.fromMillisecondsSinceEpoch(state.createdDate.toInt())}',
|
||||
);
|
||||
buffer.writeln(
|
||||
'Last updated at: ${DateTime.fromMillisecondsSinceEpoch(state.lastUpdatedDate.toInt())}');
|
||||
'Last updated at: ${DateTime.fromMillisecondsSinceEpoch(state.lastUpdatedDate.toInt())}',
|
||||
);
|
||||
buffer.writeln();
|
||||
buffer.writeln('Engine Repo');
|
||||
buffer.writeln('\tCandidate branch: ${state.engine.candidateBranch}');
|
||||
@@ -91,7 +89,8 @@ String presentState(pb.ConductorState state) {
|
||||
buffer.writeln('\tCurrent git HEAD: ${state.engine.currentGitHead}');
|
||||
buffer.writeln('\tPath to checkout: ${state.engine.checkoutPath}');
|
||||
buffer.writeln(
|
||||
'\tPost-submit LUCI dashboard: ${luciConsoleLink(state.engine.candidateBranch, 'engine')}');
|
||||
'\tPost-submit LUCI dashboard: ${luciConsoleLink(state.engine.candidateBranch, 'engine')}',
|
||||
);
|
||||
if (state.engine.cherrypicks.isNotEmpty) {
|
||||
buffer.writeln('${state.engine.cherrypicks.length} Engine Cherrypicks:');
|
||||
for (final pb.Cherrypick cherrypick in state.engine.cherrypicks) {
|
||||
@@ -109,10 +108,10 @@ String presentState(pb.ConductorState state) {
|
||||
buffer.writeln('\tCurrent git HEAD: ${state.framework.currentGitHead}');
|
||||
buffer.writeln('\tPath to checkout: ${state.framework.checkoutPath}');
|
||||
buffer.writeln(
|
||||
'\tPost-submit LUCI dashboard: ${luciConsoleLink(state.framework.candidateBranch, 'flutter')}');
|
||||
'\tPost-submit LUCI dashboard: ${luciConsoleLink(state.framework.candidateBranch, 'flutter')}',
|
||||
);
|
||||
if (state.framework.cherrypicks.isNotEmpty) {
|
||||
buffer.writeln(
|
||||
'${state.framework.cherrypicks.length} Framework Cherrypicks:');
|
||||
buffer.writeln('${state.framework.cherrypicks.length} Framework Cherrypicks:');
|
||||
for (final pb.Cherrypick cherrypick in state.framework.cherrypicks) {
|
||||
buffer.writeln('\t${cherrypick.trunkRevision} - ${cherrypick.state}');
|
||||
}
|
||||
@@ -196,12 +195,10 @@ String phaseInstructions(pb.ConductorState state) {
|
||||
].join('\n');
|
||||
case ReleasePhase.APPLY_FRAMEWORK_CHERRYPICKS:
|
||||
final List<pb.Cherrypick> outstandingCherrypicks =
|
||||
state.framework.cherrypicks.where(
|
||||
(pb.Cherrypick cp) {
|
||||
return cp.state == pb.CherrypickState.PENDING ||
|
||||
cp.state == pb.CherrypickState.PENDING_WITH_CONFLICT;
|
||||
},
|
||||
).toList();
|
||||
state.framework.cherrypicks.where((pb.Cherrypick cp) {
|
||||
return cp.state == pb.CherrypickState.PENDING ||
|
||||
cp.state == pb.CherrypickState.PENDING_WITH_CONFLICT;
|
||||
}).toList();
|
||||
if (outstandingCherrypicks.isNotEmpty) {
|
||||
return <String>[
|
||||
'You must now manually apply the following framework cherrypicks to the checkout',
|
||||
@@ -256,7 +253,8 @@ String phaseInstructions(pb.ConductorState state) {
|
||||
/// Second group = account name
|
||||
/// Third group = repo name
|
||||
final RegExp githubRemotePattern = RegExp(
|
||||
r'^(git@github\.com:|https?:\/\/github\.com\/)([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)(\.git)?$');
|
||||
r'^(git@github\.com:|https?:\/\/github\.com\/)([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)(\.git)?$',
|
||||
);
|
||||
|
||||
/// Parses a Git remote URL and returns the account name.
|
||||
///
|
||||
@@ -265,15 +263,11 @@ String githubAccount(String remoteUrl) {
|
||||
final String engineUrl = remoteUrl;
|
||||
final RegExpMatch? match = githubRemotePattern.firstMatch(engineUrl);
|
||||
if (match == null) {
|
||||
throw globals.ConductorException(
|
||||
'Cannot determine the GitHub account from $engineUrl',
|
||||
);
|
||||
throw globals.ConductorException('Cannot determine the GitHub account from $engineUrl');
|
||||
}
|
||||
final String? accountName = match.group(2);
|
||||
if (accountName == null || accountName.isEmpty) {
|
||||
throw globals.ConductorException(
|
||||
'Cannot determine the GitHub account from $match',
|
||||
);
|
||||
throw globals.ConductorException('Cannot determine the GitHub account from $match');
|
||||
}
|
||||
return accountName;
|
||||
}
|
||||
@@ -304,18 +298,13 @@ const JsonEncoder _encoder = JsonEncoder.withIndent(' ');
|
||||
|
||||
void writeStateToFile(File file, pb.ConductorState state, List<String> logs) {
|
||||
state.logs.addAll(logs);
|
||||
file.writeAsStringSync(
|
||||
_encoder.convert(state.toProto3Json()),
|
||||
flush: true,
|
||||
);
|
||||
file.writeAsStringSync(_encoder.convert(state.toProto3Json()), flush: true);
|
||||
}
|
||||
|
||||
pb.ConductorState readStateFromFile(File file) {
|
||||
final pb.ConductorState state = pb.ConductorState();
|
||||
final String stateAsString = file.readAsStringSync();
|
||||
state.mergeFromProto3Json(
|
||||
jsonDecode(stateAsString),
|
||||
);
|
||||
state.mergeFromProto3Json(jsonDecode(stateAsString));
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -341,8 +330,9 @@ bool requiresFrameworkPR(pb.ConductorState state) {
|
||||
if (requiresEnginePR(state)) {
|
||||
return true;
|
||||
}
|
||||
final bool hasRequiredCherrypicks = state.framework.cherrypicks
|
||||
.any((pb.Cherrypick cp) => cp.state != pb.CherrypickState.ABANDONED);
|
||||
final bool hasRequiredCherrypicks = state.framework.cherrypicks.any(
|
||||
(pb.Cherrypick cp) => cp.state != pb.CherrypickState.ABANDONED,
|
||||
);
|
||||
if (hasRequiredCherrypicks) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,22 +16,17 @@ const String kStateOption = 'state-file';
|
||||
|
||||
/// Command to print the status of the current Flutter release.
|
||||
class StatusCommand extends Command<void> {
|
||||
StatusCommand({
|
||||
required this.checkouts,
|
||||
}) : platform = checkouts.platform,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
StatusCommand({required this.checkouts})
|
||||
: platform = checkouts.platform,
|
||||
fileSystem = checkouts.fileSystem,
|
||||
stdio = checkouts.stdio {
|
||||
final String defaultPath = defaultStateFilePath(platform);
|
||||
argParser.addOption(
|
||||
kStateOption,
|
||||
defaultsTo: defaultPath,
|
||||
help: 'Path to persistent state file. Defaults to $defaultPath',
|
||||
);
|
||||
argParser.addFlag(
|
||||
kVerboseFlag,
|
||||
abbr: 'v',
|
||||
help: 'Also print logs.',
|
||||
);
|
||||
argParser.addFlag(kVerboseFlag, abbr: 'v', help: 'Also print logs.');
|
||||
}
|
||||
|
||||
final Checkouts checkouts;
|
||||
@@ -49,8 +44,7 @@ class StatusCommand extends Command<void> {
|
||||
void run() {
|
||||
final File stateFile = checkouts.fileSystem.file(argResults![kStateOption]);
|
||||
if (!stateFile.existsSync()) {
|
||||
stdio.printStatus(
|
||||
'No persistent state file found at ${argResults![kStateOption]}.');
|
||||
stdio.printStatus('No persistent state file found at ${argResults![kStateOption]}.');
|
||||
return;
|
||||
}
|
||||
final pb.ConductorState state = readStateFromFile(stateFile);
|
||||
|
||||
@@ -66,18 +66,10 @@ abstract class Stdio {
|
||||
|
||||
/// A logger that will print out trace messages.
|
||||
class VerboseStdio extends Stdio {
|
||||
VerboseStdio({
|
||||
required this.stdout,
|
||||
required this.stderr,
|
||||
required this.stdin,
|
||||
this.filter,
|
||||
});
|
||||
VerboseStdio({required this.stdout, required this.stderr, required this.stdin, this.filter});
|
||||
|
||||
factory VerboseStdio.local() => VerboseStdio(
|
||||
stdout: io.stdout,
|
||||
stderr: io.stderr,
|
||||
stdin: io.stdin,
|
||||
);
|
||||
factory VerboseStdio.local() =>
|
||||
VerboseStdio(stdout: io.stdout, stderr: io.stderr, stdin: io.stdin);
|
||||
|
||||
final io.Stdout stdout;
|
||||
final io.Stdout stderr;
|
||||
|
||||
@@ -23,10 +23,11 @@ sealed class CheckoutStatePostGradleRegeneration {
|
||||
changedPaths.add(match.group(1)!);
|
||||
}
|
||||
|
||||
final List<String> nonLockfileDiffs = changedPaths.where((String path) {
|
||||
final String extension = context.extension(path);
|
||||
return extension != '.lockfile';
|
||||
}).toList();
|
||||
final List<String> nonLockfileDiffs =
|
||||
changedPaths.where((String path) {
|
||||
final String extension = context.extension(path);
|
||||
return extension != '.lockfile';
|
||||
}).toList();
|
||||
|
||||
if (nonLockfileDiffs.isNotEmpty) {
|
||||
return NonLockfileChanges(nonLockfileDiffs);
|
||||
|
||||
@@ -73,22 +73,14 @@ class Version {
|
||||
/// `flutter --version` and match one of `stablePattern`, `developmentPattern`
|
||||
/// and `latestPattern`.
|
||||
factory Version.fromString(String versionString) {
|
||||
|
||||
versionString = versionString.trim();
|
||||
// stable tag
|
||||
Match? match = versionPatterns[VersionType.stable]!.firstMatch(versionString);
|
||||
if (match != null) {
|
||||
// parse stable
|
||||
final List<int> parts = match
|
||||
.groups(<int>[1, 2, 3])
|
||||
.map((String? s) => int.parse(s!))
|
||||
.toList();
|
||||
return Version(
|
||||
x: parts[0],
|
||||
y: parts[1],
|
||||
z: parts[2],
|
||||
type: VersionType.stable,
|
||||
);
|
||||
final List<int> parts =
|
||||
match.groups(<int>[1, 2, 3]).map((String? s) => int.parse(s!)).toList();
|
||||
return Version(x: parts[0], y: parts[1], z: parts[2], type: VersionType.stable);
|
||||
}
|
||||
// development tag
|
||||
match = versionPatterns[VersionType.development]!.firstMatch(versionString);
|
||||
@@ -109,11 +101,8 @@ class Version {
|
||||
match = versionPatterns[VersionType.latest]!.firstMatch(versionString);
|
||||
if (match != null) {
|
||||
// parse latest
|
||||
final List<int> parts = match.groups(
|
||||
<int>[1, 2, 3, 4, 5, 6],
|
||||
).map(
|
||||
(String? s) => int.parse(s!),
|
||||
).toList();
|
||||
final List<int> parts =
|
||||
match.groups(<int>[1, 2, 3, 4, 5, 6]).map((String? s) => int.parse(s!)).toList();
|
||||
return Version(
|
||||
x: parts[0],
|
||||
y: parts[1],
|
||||
@@ -133,15 +122,7 @@ class Version {
|
||||
final int? m = int.tryParse(match.group(5) ?? '');
|
||||
final int? n = int.tryParse(match.group(6) ?? '');
|
||||
final int commits = int.parse(match.group(7)!);
|
||||
return Version(
|
||||
x: x,
|
||||
y: y,
|
||||
z: z,
|
||||
m: m,
|
||||
n: n,
|
||||
commits: commits,
|
||||
type: VersionType.gitDescribe,
|
||||
);
|
||||
return Version(x: x, y: y, z: z, m: m, n: n, commits: commits, type: VersionType.gitDescribe);
|
||||
}
|
||||
throw Exception('${versionString.trim()} cannot be parsed');
|
||||
}
|
||||
@@ -160,7 +141,8 @@ class Version {
|
||||
int? nextN = previousVersion.n;
|
||||
nextVersionType ??= switch (previousVersion.type) {
|
||||
VersionType.stable => VersionType.stable,
|
||||
VersionType.latest || VersionType.gitDescribe || VersionType.development => VersionType.development,
|
||||
VersionType.latest || VersionType.gitDescribe || VersionType.development =>
|
||||
VersionType.development,
|
||||
};
|
||||
|
||||
switch (increment) {
|
||||
@@ -180,21 +162,17 @@ class Version {
|
||||
assert(previousVersion.type == VersionType.stable);
|
||||
nextZ += 1;
|
||||
case 'm':
|
||||
assert(false, "Do not increment 'm' via Version.increment, use instead Version.fromCandidateBranch()");
|
||||
assert(
|
||||
false,
|
||||
"Do not increment 'm' via Version.increment, use instead Version.fromCandidateBranch()",
|
||||
);
|
||||
case 'n':
|
||||
// Hotfix to internal roll.
|
||||
nextN = nextN! + 1;
|
||||
default:
|
||||
throw Exception('Unknown increment level $increment.');
|
||||
}
|
||||
return Version(
|
||||
x: nextX,
|
||||
y: nextY,
|
||||
z: nextZ,
|
||||
m: nextM,
|
||||
n: nextN,
|
||||
type: nextVersionType,
|
||||
);
|
||||
return Version(x: nextX, y: nextY, z: nextZ, m: nextM, n: nextN, type: nextVersionType);
|
||||
}
|
||||
|
||||
factory Version.fromCandidateBranch(String branchName) {
|
||||
@@ -209,17 +187,12 @@ class Version {
|
||||
y = int.parse(match.group(2)!);
|
||||
m = int.parse(match.group(3)!);
|
||||
} on Exception {
|
||||
throw ConductorException('branch named $branchName not recognized as a valid candidate branch');
|
||||
throw ConductorException(
|
||||
'branch named $branchName not recognized as a valid candidate branch',
|
||||
);
|
||||
}
|
||||
|
||||
return Version(
|
||||
type: VersionType.development,
|
||||
x: x,
|
||||
y: y,
|
||||
z: 0,
|
||||
m: m,
|
||||
n: 0,
|
||||
);
|
||||
return Version(type: VersionType.development, x: x, y: y, z: 0, m: m, n: 0);
|
||||
}
|
||||
|
||||
/// Major version.
|
||||
@@ -279,7 +252,9 @@ class Version {
|
||||
}
|
||||
|
||||
// stable type versions don't have an m field set
|
||||
if (type != VersionType.stable && releaseType != ReleaseType.STABLE_HOTFIX && releaseType != ReleaseType.STABLE_INITIAL) {
|
||||
if (type != VersionType.stable &&
|
||||
releaseType != ReleaseType.STABLE_HOTFIX &&
|
||||
releaseType != ReleaseType.STABLE_INITIAL) {
|
||||
final String branchM = branchMatch.group(3)!;
|
||||
if (m != int.tryParse(branchM)) {
|
||||
throw ConductorException(
|
||||
@@ -293,9 +268,9 @@ class Version {
|
||||
@override
|
||||
String toString() {
|
||||
return switch (type) {
|
||||
VersionType.stable => '$x.$y.$z',
|
||||
VersionType.stable => '$x.$y.$z',
|
||||
VersionType.development => '$x.$y.$z-$m.$n.pre',
|
||||
VersionType.latest => '$x.$y.$z-$m.$n.pre.$commits',
|
||||
VersionType.latest => '$x.$y.$z-$m.$n.pre.$commits',
|
||||
VersionType.gitDescribe => '$x.$y.$z-$m.$n.pre.$commits',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,143 +11,137 @@ import 'package:platform/platform.dart';
|
||||
import './common.dart';
|
||||
|
||||
void main() {
|
||||
group('candidates command', () {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String flutterBinPath = '$flutterRoot/bin/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
const String remoteName = 'origin';
|
||||
group(
|
||||
'candidates command',
|
||||
() {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String flutterBinPath = '$flutterRoot/bin/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
const String remoteName = 'origin';
|
||||
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
});
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
});
|
||||
|
||||
CommandRunner<void> createRunner({
|
||||
required Checkouts checkouts,
|
||||
}) {
|
||||
final CandidatesCommand command = CandidatesCommand(
|
||||
checkouts: checkouts,
|
||||
flutterRoot: fileSystem.directory(flutterRoot),
|
||||
);
|
||||
return CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
}
|
||||
CommandRunner<void> createRunner({required Checkouts checkouts}) {
|
||||
final CandidatesCommand command = CandidatesCommand(
|
||||
checkouts: checkouts,
|
||||
flutterRoot: fileSystem.directory(flutterRoot),
|
||||
);
|
||||
return CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
}
|
||||
|
||||
test('prints only branches from targeted remote', () async {
|
||||
const String currentVersion = '1.2.3';
|
||||
const String branch = 'flutter-1.3-candidate.0';
|
||||
test('prints only branches from targeted remote', () async {
|
||||
const String currentVersion = '1.2.3';
|
||||
const String branch = 'flutter-1.3-candidate.0';
|
||||
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'fetch', remoteName],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, 'help'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, '--version', '--machine'],
|
||||
stdout: '{"frameworkVersion": "$currentVersion"}',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'branch',
|
||||
'--no-color',
|
||||
'--remotes',
|
||||
'--list',
|
||||
'$remoteName/*',
|
||||
],
|
||||
stdout: <String>[
|
||||
'other-remote/flutter-5.0-candidate.0',
|
||||
'$remoteName/$branch',
|
||||
].join('\n'),
|
||||
),
|
||||
]);
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: <String>['git', 'fetch', remoteName]),
|
||||
const FakeCommand(command: <String>[flutterBinPath, 'help']),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, '--version', '--machine'],
|
||||
stdout: '{"frameworkVersion": "$currentVersion"}',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'branch',
|
||||
'--no-color',
|
||||
'--remotes',
|
||||
'--list',
|
||||
'$remoteName/*',
|
||||
],
|
||||
stdout: <String>[
|
||||
'other-remote/flutter-5.0-candidate.0',
|
||||
'$remoteName/$branch',
|
||||
].join('\n'),
|
||||
),
|
||||
]);
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
||||
},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
||||
},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final CommandRunner<void> runner = createRunner(checkouts: checkouts);
|
||||
await runner.run(<String>['candidates', '--$kRemote', remoteName]);
|
||||
expect(stdio.stdout.contains('currentVersion = $currentVersion'), true);
|
||||
expect(stdio.stdout.contains(branch), true);
|
||||
expect(stdio.stdout.contains('flutter-5.0-candidate.0'), false);
|
||||
});
|
||||
final CommandRunner<void> runner = createRunner(checkouts: checkouts);
|
||||
await runner.run(<String>['candidates', '--$kRemote', remoteName]);
|
||||
expect(stdio.stdout.contains('currentVersion = $currentVersion'), true);
|
||||
expect(stdio.stdout.contains(branch), true);
|
||||
expect(stdio.stdout.contains('flutter-5.0-candidate.0'), false);
|
||||
});
|
||||
|
||||
test('does not print branches older or equal to current version', () async {
|
||||
const String currentVersion = '2.3.0-13.0.pre.48';
|
||||
const String newBranch = 'flutter-2.4-candidate.0';
|
||||
const String oldBranch = 'flutter-1.0-candidate.0';
|
||||
const String currentBranch = 'flutter-2.3-candidate.13';
|
||||
test('does not print branches older or equal to current version', () async {
|
||||
const String currentVersion = '2.3.0-13.0.pre.48';
|
||||
const String newBranch = 'flutter-2.4-candidate.0';
|
||||
const String oldBranch = 'flutter-1.0-candidate.0';
|
||||
const String currentBranch = 'flutter-2.3-candidate.13';
|
||||
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'fetch', remoteName],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, 'help'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, '--version', '--machine'],
|
||||
stdout: '{"frameworkVersion": "$currentVersion"}',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'branch',
|
||||
'--no-color',
|
||||
'--remotes',
|
||||
'--list',
|
||||
'$remoteName/*',
|
||||
],
|
||||
stdout: <String>[
|
||||
'$remoteName/$oldBranch',
|
||||
'$remoteName/$currentBranch',
|
||||
'$remoteName/$newBranch',
|
||||
].join('\n'),
|
||||
),
|
||||
]);
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: <String>['git', 'fetch', remoteName]),
|
||||
const FakeCommand(command: <String>[flutterBinPath, 'help']),
|
||||
const FakeCommand(
|
||||
command: <String>[flutterBinPath, '--version', '--machine'],
|
||||
stdout: '{"frameworkVersion": "$currentVersion"}',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'branch',
|
||||
'--no-color',
|
||||
'--remotes',
|
||||
'--list',
|
||||
'$remoteName/*',
|
||||
],
|
||||
stdout: <String>[
|
||||
'$remoteName/$oldBranch',
|
||||
'$remoteName/$currentBranch',
|
||||
'$remoteName/$newBranch',
|
||||
].join('\n'),
|
||||
),
|
||||
]);
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
||||
},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
||||
},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final CommandRunner<void> runner = createRunner(checkouts: checkouts);
|
||||
await runner.run(<String>['candidates', '--$kRemote', remoteName]);
|
||||
expect(stdio.stdout.contains('currentVersion = $currentVersion'), true);
|
||||
expect(stdio.stdout.contains(newBranch), true);
|
||||
expect(stdio.stdout.contains(oldBranch), false);
|
||||
expect(stdio.stdout.contains(currentBranch), false);
|
||||
});
|
||||
}, onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
});
|
||||
final CommandRunner<void> runner = createRunner(checkouts: checkouts);
|
||||
await runner.run(<String>['candidates', '--$kRemote', remoteName]);
|
||||
expect(stdio.stdout.contains('currentVersion = $currentVersion'), true);
|
||||
expect(stdio.stdout.contains(newBranch), true);
|
||||
expect(stdio.stdout.contains(oldBranch), false);
|
||||
expect(stdio.stdout.contains(currentBranch), false);
|
||||
});
|
||||
},
|
||||
onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,83 +12,69 @@ import 'package:platform/platform.dart';
|
||||
import './common.dart';
|
||||
|
||||
void main() {
|
||||
group('clean command', () {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
const String stateFilePath = '/state-file.json';
|
||||
group(
|
||||
'clean command',
|
||||
() {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
const String stateFilePath = '/state-file.json';
|
||||
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
late CommandRunner<void> runner;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
late CommandRunner<void> runner;
|
||||
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
|
||||
processManager = FakeProcessManager.empty();
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{'HOME': '/path/to/user/home'},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final CleanCommand command = CleanCommand(
|
||||
checkouts: checkouts,
|
||||
);
|
||||
runner = CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
});
|
||||
processManager = FakeProcessManager.empty();
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{'HOME': '/path/to/user/home'},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final CleanCommand command = CleanCommand(checkouts: checkouts);
|
||||
runner = CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
});
|
||||
|
||||
test('throws if no state file found', () async {
|
||||
await expectLater(
|
||||
() async => runner.run(<String>[
|
||||
'clean',
|
||||
'--$kStateOption',
|
||||
stateFilePath,
|
||||
'--$kYesFlag',
|
||||
]),
|
||||
throwsExceptionWith(
|
||||
'No persistent state file found at $stateFilePath',
|
||||
),
|
||||
);
|
||||
});
|
||||
test('throws if no state file found', () async {
|
||||
await expectLater(
|
||||
() async =>
|
||||
runner.run(<String>['clean', '--$kStateOption', stateFilePath, '--$kYesFlag']),
|
||||
throwsExceptionWith('No persistent state file found at $stateFilePath'),
|
||||
);
|
||||
});
|
||||
|
||||
test('deletes an empty state file', () async {
|
||||
final File stateFile = fileSystem.file(stateFilePath);
|
||||
stateFile.writeAsStringSync('');
|
||||
test('deletes an empty state file', () async {
|
||||
final File stateFile = fileSystem.file(stateFilePath);
|
||||
stateFile.writeAsStringSync('');
|
||||
|
||||
await runner.run(<String>[
|
||||
'clean',
|
||||
'--$kStateOption',
|
||||
stateFile.path,
|
||||
'--$kYesFlag',
|
||||
]);
|
||||
await runner.run(<String>['clean', '--$kStateOption', stateFile.path, '--$kYesFlag']);
|
||||
|
||||
expect(stateFile.existsSync(), false);
|
||||
});
|
||||
expect(stateFile.existsSync(), false);
|
||||
});
|
||||
|
||||
test('deletes a state file with content', () async {
|
||||
final File stateFile = fileSystem.file(stateFilePath);
|
||||
stateFile.writeAsStringSync('{status: pending}');
|
||||
test('deletes a state file with content', () async {
|
||||
final File stateFile = fileSystem.file(stateFilePath);
|
||||
stateFile.writeAsStringSync('{status: pending}');
|
||||
|
||||
await runner.run(<String>[
|
||||
'clean',
|
||||
'--$kStateOption',
|
||||
stateFile.path,
|
||||
'--$kYesFlag',
|
||||
]);
|
||||
await runner.run(<String>['clean', '--$kStateOption', stateFile.path, '--$kYesFlag']);
|
||||
|
||||
expect(stateFile.existsSync(), false);
|
||||
});
|
||||
}, onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
});
|
||||
expect(stateFile.existsSync(), false);
|
||||
});
|
||||
},
|
||||
onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,35 +13,36 @@ export '../../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
||||
|
||||
Matcher throwsAssertionWith(String messageSubString) {
|
||||
return throwsA(
|
||||
isA<AssertionError>().having(
|
||||
(AssertionError e) => e.toString(),
|
||||
'description',
|
||||
contains(messageSubString),
|
||||
),
|
||||
isA<AssertionError>().having(
|
||||
(AssertionError e) => e.toString(),
|
||||
'description',
|
||||
contains(messageSubString),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Matcher throwsExceptionWith(String messageSubString) {
|
||||
return throwsA(
|
||||
isA<Exception>().having(
|
||||
(Exception e) => e.toString(),
|
||||
'description',
|
||||
contains(messageSubString),
|
||||
),
|
||||
isA<Exception>().having(
|
||||
(Exception e) => e.toString(),
|
||||
'description',
|
||||
contains(messageSubString),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class TestStdio extends Stdio {
|
||||
TestStdio({
|
||||
this.verbose = false,
|
||||
List<String>? stdin,
|
||||
}) : stdin = stdin ?? <String>[];
|
||||
TestStdio({this.verbose = false, List<String>? stdin}) : stdin = stdin ?? <String>[];
|
||||
|
||||
String get error => logs.where((String log) => log.startsWith(r'[error] ')).join('\n');
|
||||
|
||||
String get stdout => logs.where((String log) {
|
||||
return log.startsWith(r'[status] ') || log.startsWith(r'[trace] ') || log.startsWith(r'[write] ');
|
||||
}).join('\n');
|
||||
String get stdout => logs
|
||||
.where((String log) {
|
||||
return log.startsWith(r'[status] ') ||
|
||||
log.startsWith(r'[trace] ') ||
|
||||
log.startsWith(r'[write] ');
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
final bool verbose;
|
||||
final List<String> stdin;
|
||||
@@ -66,15 +67,15 @@ class FakeArgResults extends Fake implements ArgResults {
|
||||
bool force = false,
|
||||
bool skipTagging = false,
|
||||
}) : _parsedArgs = <String, dynamic>{
|
||||
'increment': level,
|
||||
'candidate-branch': candidateBranch,
|
||||
'remote': remote,
|
||||
'just-print': justPrint,
|
||||
'yes': autoApprove,
|
||||
'help': help,
|
||||
'force': force,
|
||||
'skip-tagging': skipTagging,
|
||||
};
|
||||
'increment': level,
|
||||
'candidate-branch': candidateBranch,
|
||||
'remote': remote,
|
||||
'just-print': justPrint,
|
||||
'yes': autoApprove,
|
||||
'help': help,
|
||||
'force': force,
|
||||
'skip-tagging': skipTagging,
|
||||
};
|
||||
|
||||
@override
|
||||
String? name;
|
||||
|
||||
@@ -22,8 +22,7 @@ void main() {
|
||||
const String dartRevision = 'fe9708ab688dcda9923f584ba370a66fcbc3811f';
|
||||
const String engineCherrypick1 = 'a5a25cd702b062c24b2c67b8d30b5cb33e0ef6f0';
|
||||
const String engineCherrypick2 = '94d06a2e1d01a3b0c693b94d70c5e1df9d78d249';
|
||||
const String frameworkCherrypick =
|
||||
'a5a25cd702b062c24b2c67b8d30b5cb33e0ef6f0';
|
||||
const String frameworkCherrypick = 'a5a25cd702b062c24b2c67b8d30b5cb33e0ef6f0';
|
||||
|
||||
final RegExp titlePattern = RegExp(r'&title=(.*)&');
|
||||
final RegExp bodyPattern = RegExp(r'&body=(.*)$');
|
||||
@@ -31,61 +30,41 @@ void main() {
|
||||
late pb.ConductorState state;
|
||||
|
||||
setUp(() {
|
||||
state = (pb.ConductorState.create()
|
||||
..engine = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..cherrypicks.addAll(<pb.Cherrypick>[
|
||||
pb.Cherrypick.create()
|
||||
..trunkRevision = engineCherrypick1,
|
||||
pb.Cherrypick.create()
|
||||
..trunkRevision = engineCherrypick2,
|
||||
])
|
||||
..dartRevision = dartRevision
|
||||
..workingBranch = workingBranch
|
||||
)
|
||||
..framework = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..cherrypicks.add(pb.Cherrypick.create()
|
||||
..trunkRevision = frameworkCherrypick
|
||||
)
|
||||
..workingBranch = workingBranch
|
||||
)
|
||||
..releaseChannel = releaseChannel
|
||||
..releaseVersion = releaseVersion
|
||||
);
|
||||
state =
|
||||
(pb.ConductorState.create()
|
||||
..engine =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..cherrypicks.addAll(<pb.Cherrypick>[
|
||||
pb.Cherrypick.create()..trunkRevision = engineCherrypick1,
|
||||
pb.Cherrypick.create()..trunkRevision = engineCherrypick2,
|
||||
])
|
||||
..dartRevision = dartRevision
|
||||
..workingBranch = workingBranch)
|
||||
..framework =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..cherrypicks.add(pb.Cherrypick.create()..trunkRevision = frameworkCherrypick)
|
||||
..workingBranch = workingBranch)
|
||||
..releaseChannel = releaseChannel
|
||||
..releaseVersion = releaseVersion);
|
||||
});
|
||||
|
||||
test('throws on an invalid repoName', () {
|
||||
expect(
|
||||
() => getNewPrLink(
|
||||
repoName: 'flooter',
|
||||
userName: userName,
|
||||
state: state,
|
||||
),
|
||||
throwsExceptionWith(
|
||||
'Expected repoName to be one of flutter or engine but got flooter.',
|
||||
),
|
||||
() => getNewPrLink(repoName: 'flooter', userName: userName, state: state),
|
||||
throwsExceptionWith('Expected repoName to be one of flutter or engine but got flooter.'),
|
||||
);
|
||||
});
|
||||
|
||||
test('returns a valid URL for engine', () {
|
||||
final String link = getNewPrLink(
|
||||
repoName: 'engine',
|
||||
userName: userName,
|
||||
state: state,
|
||||
);
|
||||
final String link = getNewPrLink(repoName: 'engine', userName: userName, state: state);
|
||||
expect(link, contains('https://github.com/flutter/engine/compare/'));
|
||||
expect(link, contains('$candidateBranch...$userName:$workingBranch?expand=1'));
|
||||
expect(
|
||||
link,
|
||||
contains('https://github.com/flutter/engine/compare/'),
|
||||
Uri.decodeQueryComponent(titlePattern.firstMatch(link)?.group(1) ?? ''),
|
||||
'[flutter_releases] Flutter $releaseChannel $releaseVersion Engine Cherrypicks',
|
||||
);
|
||||
expect(
|
||||
link,
|
||||
contains('$candidateBranch...$userName:$workingBranch?expand=1'),
|
||||
);
|
||||
expect(
|
||||
Uri.decodeQueryComponent(
|
||||
titlePattern.firstMatch(link)?.group(1) ?? ''),
|
||||
'[flutter_releases] Flutter $releaseChannel $releaseVersion Engine Cherrypicks');
|
||||
final String expectedBody = '''
|
||||
# Flutter $releaseChannel $releaseVersion Engine
|
||||
|
||||
@@ -95,30 +74,17 @@ void main() {
|
||||
- commit: flutter/engine@${engineCherrypick1.substring(0, 9)}
|
||||
- commit: flutter/engine@${engineCherrypick2.substring(0, 9)}
|
||||
''';
|
||||
expect(
|
||||
Uri.decodeQueryComponent(bodyPattern.firstMatch(link)?.group(1) ?? ''),
|
||||
expectedBody,
|
||||
);
|
||||
expect(Uri.decodeQueryComponent(bodyPattern.firstMatch(link)?.group(1) ?? ''), expectedBody);
|
||||
});
|
||||
|
||||
test('returns a valid URL for framework', () {
|
||||
final String link = getNewPrLink(
|
||||
repoName: 'flutter',
|
||||
userName: userName,
|
||||
state: state,
|
||||
);
|
||||
final String link = getNewPrLink(repoName: 'flutter', userName: userName, state: state);
|
||||
expect(link, contains('https://github.com/flutter/flutter/compare/'));
|
||||
expect(link, contains('$candidateBranch...$userName:$workingBranch?expand=1'));
|
||||
expect(
|
||||
link,
|
||||
contains('https://github.com/flutter/flutter/compare/'),
|
||||
Uri.decodeQueryComponent(titlePattern.firstMatch(link)?.group(1) ?? ''),
|
||||
'[flutter_releases] Flutter $releaseChannel $releaseVersion Framework Cherrypicks',
|
||||
);
|
||||
expect(
|
||||
link,
|
||||
contains('$candidateBranch...$userName:$workingBranch?expand=1'),
|
||||
);
|
||||
expect(
|
||||
Uri.decodeQueryComponent(
|
||||
titlePattern.firstMatch(link)?.group(1) ?? ''),
|
||||
'[flutter_releases] Flutter $releaseChannel $releaseVersion Framework Cherrypicks');
|
||||
final String expectedBody = '''
|
||||
# Flutter $releaseChannel $releaseVersion Framework
|
||||
|
||||
@@ -126,10 +92,7 @@ void main() {
|
||||
|
||||
- commit: ${frameworkCherrypick.substring(0, 9)}
|
||||
''';
|
||||
expect(
|
||||
Uri.decodeQueryComponent(bodyPattern.firstMatch(link)?.group(1) ?? ''),
|
||||
expectedBody,
|
||||
);
|
||||
expect(Uri.decodeQueryComponent(bodyPattern.firstMatch(link)?.group(1) ?? ''), expectedBody);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -137,28 +100,16 @@ void main() {
|
||||
const String flagName = 'a-cli-flag';
|
||||
|
||||
test('prefers env over argResults', () {
|
||||
final ArgResults argResults = FakeArgs(results: <String, Object>{
|
||||
flagName: false,
|
||||
});
|
||||
final ArgResults argResults = FakeArgs(results: <String, Object>{flagName: false});
|
||||
final Map<String, String> env = <String, String>{'A_CLI_FLAG': 'TRUE'};
|
||||
final bool result = getBoolFromEnvOrArgs(
|
||||
flagName,
|
||||
argResults,
|
||||
env,
|
||||
);
|
||||
final bool result = getBoolFromEnvOrArgs(flagName, argResults, env);
|
||||
expect(result, true);
|
||||
});
|
||||
|
||||
test('falls back to argResults if env is empty', () {
|
||||
final ArgResults argResults = FakeArgs(results: <String, Object>{
|
||||
flagName: false,
|
||||
});
|
||||
final ArgResults argResults = FakeArgs(results: <String, Object>{flagName: false});
|
||||
final Map<String, String> env = <String, String>{};
|
||||
final bool result = getBoolFromEnvOrArgs(
|
||||
flagName,
|
||||
argResults,
|
||||
env,
|
||||
);
|
||||
final bool result = getBoolFromEnvOrArgs(flagName, argResults, env);
|
||||
expect(result, false);
|
||||
});
|
||||
});
|
||||
@@ -185,7 +136,7 @@ class FakeArgs extends Fake implements ArgResults {
|
||||
}
|
||||
|
||||
@override
|
||||
Object? operator[](String name) {
|
||||
Object? operator [](String name) {
|
||||
return results[name];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,16 +44,12 @@ void main() {
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory)
|
||||
..createSync(recursive: true),
|
||||
parentDirectory: fileSystem.directory(checkoutsParentDirectory)..createSync(recursive: true),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
framework = FrameworkRepository(
|
||||
checkouts,
|
||||
mirrorRemote: const Remote.mirror(mirrorUrl),
|
||||
);
|
||||
framework = FrameworkRepository(checkouts, mirrorRemote: const Remote.mirror(mirrorUrl));
|
||||
|
||||
autoroller = PackageAutoroller(
|
||||
githubClient: githubClient,
|
||||
@@ -67,104 +63,81 @@ void main() {
|
||||
});
|
||||
|
||||
test('GitHub token is redacted from exceptions while pushing', () async {
|
||||
final StreamController<List<int>> controller =
|
||||
StreamController<List<int>>();
|
||||
final StreamController<List<int>> controller = StreamController<List<int>>();
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
], stdin: io.IOSink(controller.sink)),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'remote',
|
||||
'add',
|
||||
'mirror',
|
||||
mirrorUrl,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'fetch',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
FrameworkRepository.defaultBranch,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: 'deadbeef'),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'ls-remote',
|
||||
'--heads',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
'-b',
|
||||
'packages-autoroller-branch-1',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'help',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
], stdout: '''
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
],
|
||||
stdin: io.IOSink(controller.sink),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', mirrorUrl]),
|
||||
const FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', FrameworkRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: 'deadbeef'),
|
||||
const FakeCommand(command: <String>['git', 'ls-remote', '--heads', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', '-b', 'packages-autoroller-branch-1']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'help',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: '''
|
||||
M packages/foo/pubspec.yaml
|
||||
M packages/bar/pubspec.yaml
|
||||
M dev/integration_tests/test_foo/pubspec.yaml
|
||||
'''),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'add',
|
||||
'--all',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'roll packages',
|
||||
'--author="fluttergithubbot <fluttergithubbot@google.com>"',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: '000deadbeef'),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'push',
|
||||
'https://$token@github.com/$orgName/flutter.git',
|
||||
'packages-autoroller-branch-1:packages-autoroller-branch-1',
|
||||
], exitCode: 1, stderr: 'Authentication error!'),
|
||||
''',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'roll packages',
|
||||
'--author="fluttergithubbot <fluttergithubbot@google.com>"',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: '000deadbeef'),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'push',
|
||||
'https://$token@github.com/$orgName/flutter.git',
|
||||
'packages-autoroller-branch-1:packages-autoroller-branch-1',
|
||||
],
|
||||
exitCode: 1,
|
||||
stderr: 'Authentication error!',
|
||||
),
|
||||
]);
|
||||
await expectLater(
|
||||
() async {
|
||||
@@ -172,45 +145,52 @@ void main() {
|
||||
await controller.stream.drain<Object?>();
|
||||
await rollFuture;
|
||||
},
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exc) => exc.toString(),
|
||||
'message',
|
||||
isNot(contains(token)),
|
||||
)),
|
||||
throwsA(
|
||||
isA<Exception>().having(
|
||||
(Exception exc) => exc.toString(),
|
||||
'message',
|
||||
isNot(contains(token)),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('Does not attempt to roll if bot already has an open PR', () async {
|
||||
final StreamController<List<int>> controller =
|
||||
StreamController<List<int>>();
|
||||
final StreamController<List<int>> controller = StreamController<List<int>>();
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
], stdin: io.IOSink(controller.sink)),
|
||||
const FakeCommand(command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Non empty array means there are open PRs by the bot with the tool label
|
||||
// We expect no further commands to be run
|
||||
], stdout: '[{"number": 123}]'),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
],
|
||||
stdin: io.IOSink(controller.sink),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Non empty array means there are open PRs by the bot with the tool label
|
||||
// We expect no further commands to be run
|
||||
],
|
||||
stdout: '[{"number": 123}]',
|
||||
),
|
||||
]);
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
await controller.stream.drain<Object?>();
|
||||
@@ -221,111 +201,90 @@ void main() {
|
||||
});
|
||||
|
||||
test('Does not commit or create a PR if no changes were made', () async {
|
||||
final StreamController<List<int>> controller =
|
||||
StreamController<List<int>>();
|
||||
final StreamController<List<int>> controller = StreamController<List<int>>();
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
], stdin: io.IOSink(controller.sink)),
|
||||
const FakeCommand(command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Returns empty array, as there are no other open roll PRs from the bot
|
||||
], stdout: '[]'),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'remote',
|
||||
'add',
|
||||
'mirror',
|
||||
mirrorUrl,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'fetch',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
FrameworkRepository.defaultBranch,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: 'deadbeef'),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
],
|
||||
stdin: io.IOSink(controller.sink),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Returns empty array, as there are no other open roll PRs from the bot
|
||||
],
|
||||
stdout: '[]',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', mirrorUrl]),
|
||||
const FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', FrameworkRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: 'deadbeef'),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||
workingDirectory:
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'compile',
|
||||
'exe',
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||
'-o',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
],
|
||||
onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync(),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['chmod', '+x', '/.tmp_rand0/rand0/generate_gradle_lockfiles'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'ls-remote', '--heads', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', '-b', 'packages-autoroller-branch-1']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
],
|
||||
),
|
||||
FakeCommand(command: const <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'compile',
|
||||
'exe',
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||
'-o',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
], onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync()),
|
||||
const FakeCommand(command: <String>[
|
||||
'chmod',
|
||||
'+x',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'ls-remote',
|
||||
'--heads',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
'-b',
|
||||
'packages-autoroller-branch-1',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
]),
|
||||
// Because there is no stdout to git status, the script should exit cleanly here
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
]),
|
||||
const FakeCommand(command: <String>['git', 'status', '--porcelain']),
|
||||
]);
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
await controller.stream.drain<Object?>();
|
||||
@@ -334,212 +293,178 @@ void main() {
|
||||
});
|
||||
|
||||
test('can roll with correct inputs', () async {
|
||||
final StreamController<List<int>> controller =
|
||||
StreamController<List<int>>();
|
||||
final StreamController<List<int>> controller = StreamController<List<int>>();
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
], stdin: io.IOSink(controller.sink)),
|
||||
const FakeCommand(command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Returns empty array, as there are no other open roll PRs from the bot
|
||||
], stdout: '[]'),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'remote',
|
||||
'add',
|
||||
'mirror',
|
||||
mirrorUrl,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'fetch',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
FrameworkRepository.defaultBranch,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: 'deadbeef'),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'login',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
'--git-protocol',
|
||||
'https',
|
||||
'--with-token',
|
||||
],
|
||||
stdin: io.IOSink(controller.sink),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'list',
|
||||
'--author',
|
||||
'flutter-pub-roller-bot',
|
||||
'--repo',
|
||||
'flutter/flutter',
|
||||
'--state',
|
||||
'open',
|
||||
'--search',
|
||||
'Roll pub packages',
|
||||
'--json',
|
||||
'number',
|
||||
// Returns empty array, as there are no other open roll PRs from the bot
|
||||
],
|
||||
stdout: '[]',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', mirrorUrl]),
|
||||
const FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', FrameworkRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: 'deadbeef'),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: '$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||
workingDirectory:
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools',
|
||||
),
|
||||
FakeCommand(command: const <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'compile',
|
||||
'exe',
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||
'-o',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
], onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync()),
|
||||
const FakeCommand(command: <String>[
|
||||
'chmod',
|
||||
'+x',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'ls-remote',
|
||||
'--heads',
|
||||
'mirror',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
'-b',
|
||||
'packages-autoroller-branch-1',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
], stdout: '''
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/dart',
|
||||
'compile',
|
||||
'exe',
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/dev/tools/bin/generate_gradle_lockfiles.dart',
|
||||
'-o',
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
],
|
||||
onRun: (_) => fileSystem.file('/.tmp_rand0/rand0/generate_gradle_lockfiles').createSync(),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['chmod', '+x', '/.tmp_rand0/rand0/generate_gradle_lockfiles'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'ls-remote', '--heads', 'mirror']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', '-b', 'packages-autoroller-branch-1']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'$checkoutsParentDirectory/flutter_conductor_checkouts/framework/bin/flutter',
|
||||
'--verbose',
|
||||
'update-packages',
|
||||
'--force-upgrade',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: '''
|
||||
M packages/foo/pubspec.yaml
|
||||
M packages/bar/pubspec.yaml
|
||||
M dev/integration_tests/test_foo/pubspec.yaml
|
||||
'''),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
], stdout: '''
|
||||
''',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: '''
|
||||
M packages/foo/pubspec.yaml
|
||||
M packages/bar/pubspec.yaml
|
||||
M dev/integration_tests/test_foo/pubspec.yaml
|
||||
'''),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'add',
|
||||
'--all',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'roll packages',
|
||||
'--author="flutter-pub-roller-bot <flutter-pub-roller-bot@google.com>"',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: '000deadbeef'),
|
||||
const FakeCommand(command: <String>[
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
'--no-gradle-generation',
|
||||
'--no-exclusion',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
], stdout: '''
|
||||
''',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'roll packages',
|
||||
'--author="flutter-pub-roller-bot <flutter-pub-roller-bot@google.com>"',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: '000deadbeef'),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'/.tmp_rand0/rand0/generate_gradle_lockfiles',
|
||||
'--no-gradle-generation',
|
||||
'--no-exclusion',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: '''
|
||||
M dev/integration_tests/ui/android/project-app.lockfile
|
||||
M examples/image_list/android/project-app.lockfile
|
||||
'''),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
], stdout: '''
|
||||
''',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: '''
|
||||
M dev/integration_tests/ui/android/project-app.lockfile
|
||||
M examples/image_list/android/project-app.lockfile
|
||||
'''),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'add',
|
||||
'--all',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'Re-generate Gradle lockfiles',
|
||||
'--author="flutter-pub-roller-bot <flutter-pub-roller-bot@google.com>"',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: '234deadbeef'),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'push',
|
||||
'https://$token@github.com/$orgName/flutter.git',
|
||||
'packages-autoroller-branch-1:packages-autoroller-branch-1',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'create',
|
||||
'--title',
|
||||
'Roll pub packages',
|
||||
'--body',
|
||||
'This PR was generated by `flutter update-packages --force-upgrade`.',
|
||||
'--head',
|
||||
'flutter-roller:packages-autoroller-branch-1',
|
||||
'--base',
|
||||
FrameworkRepository.defaultBranch,
|
||||
'--label',
|
||||
'tool',
|
||||
'--label',
|
||||
'autosubmit',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'gh',
|
||||
'auth',
|
||||
'logout',
|
||||
'--hostname',
|
||||
'github.com',
|
||||
]),
|
||||
''',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
'Re-generate Gradle lockfiles',
|
||||
'--author="flutter-pub-roller-bot <flutter-pub-roller-bot@google.com>"',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: '234deadbeef'),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'push',
|
||||
'https://$token@github.com/$orgName/flutter.git',
|
||||
'packages-autoroller-branch-1:packages-autoroller-branch-1',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'gh',
|
||||
'pr',
|
||||
'create',
|
||||
'--title',
|
||||
'Roll pub packages',
|
||||
'--body',
|
||||
'This PR was generated by `flutter update-packages --force-upgrade`.',
|
||||
'--head',
|
||||
'flutter-roller:packages-autoroller-branch-1',
|
||||
'--base',
|
||||
FrameworkRepository.defaultBranch,
|
||||
'--label',
|
||||
'tool',
|
||||
'--label',
|
||||
'autosubmit',
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['gh', 'auth', 'logout', '--hostname', 'github.com']),
|
||||
]);
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
final String givenToken =
|
||||
await controller.stream.transform(const Utf8Decoder()).join();
|
||||
final String givenToken = await controller.stream.transform(const Utf8Decoder()).join();
|
||||
expect(givenToken.trim(), token);
|
||||
await rollFuture;
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
@@ -550,16 +475,14 @@ void main() {
|
||||
|
||||
test('validates that file exists at --token option', () async {
|
||||
await expectLater(
|
||||
() => run(
|
||||
<String>['--token', tokenPath],
|
||||
fs: fileSystem,
|
||||
processManager: processManager,
|
||||
() => run(<String>['--token', tokenPath], fs: fileSystem, processManager: processManager),
|
||||
throwsA(
|
||||
isA<ArgumentError>().having(
|
||||
(ArgumentError err) => err.message,
|
||||
'message',
|
||||
contains('Provided token path $tokenPath but no file exists at'),
|
||||
),
|
||||
),
|
||||
throwsA(isA<ArgumentError>().having(
|
||||
(ArgumentError err) => err.message,
|
||||
'message',
|
||||
contains('Provided token path $tokenPath but no file exists at'),
|
||||
)),
|
||||
);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
@@ -569,16 +492,14 @@ void main() {
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('');
|
||||
await expectLater(
|
||||
() => run(
|
||||
<String>['--token', tokenPath],
|
||||
fs: fileSystem,
|
||||
processManager: processManager,
|
||||
() => run(<String>['--token', tokenPath], fs: fileSystem, processManager: processManager),
|
||||
throwsA(
|
||||
isA<ArgumentError>().having(
|
||||
(ArgumentError err) => err.message,
|
||||
'message',
|
||||
contains('Tried to read a GitHub access token from file $tokenPath but it was empty'),
|
||||
),
|
||||
),
|
||||
throwsA(isA<ArgumentError>().having(
|
||||
(ArgumentError err) => err.message,
|
||||
'message',
|
||||
contains('Tried to read a GitHub access token from file $tokenPath but it was empty'),
|
||||
)),
|
||||
);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
@@ -613,10 +534,7 @@ void main() {
|
||||
final Context ctx = Context(style: Style.posix);
|
||||
|
||||
test('empty input returns NoDiff', () {
|
||||
expect(
|
||||
CheckoutStatePostGradleRegeneration('', ctx),
|
||||
const NoDiff(),
|
||||
);
|
||||
expect(CheckoutStatePostGradleRegeneration('', ctx), const NoDiff());
|
||||
});
|
||||
|
||||
test('only *.lockfile changes returns OnlyLockfileChanges', () {
|
||||
@@ -660,6 +578,7 @@ $malformedLine
|
||||
}
|
||||
|
||||
class _NoOpStdin extends Fake implements io.Stdin {}
|
||||
|
||||
class _NoOpStdout extends Fake implements io.Stdout {
|
||||
@override
|
||||
void writeln([Object? object]) {}
|
||||
|
||||
@@ -78,42 +78,22 @@ vars = {
|
||||
const String commit2 = 'def456';
|
||||
const String message = 'This is a commit message.';
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
EngineRepository.defaultBranch,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit1),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
message,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit2),
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'checkout', EngineRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit1),
|
||||
const FakeCommand(command: <String>['git', 'status', '--porcelain']),
|
||||
const FakeCommand(command: <String>['git', 'commit', '--message', message]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit2),
|
||||
]);
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
@@ -136,41 +116,25 @@ vars = {
|
||||
const String commit2 = 'def456';
|
||||
const String message = 'This is a commit message.';
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
EngineRepository.defaultBranch,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit1),
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'checkout', EngineRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit1),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM path/to/file.txt',
|
||||
),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
'--message',
|
||||
message,
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit2),
|
||||
const FakeCommand(command: <String>['git', 'commit', '--message', message]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit2),
|
||||
]);
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
@@ -186,43 +150,47 @@ vars = {
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
});
|
||||
|
||||
test('updateCandidateBranchVersion() returns false if branch is the same as version file', () async {
|
||||
const String branch = 'flutter-2.15-candidate.3';
|
||||
final File versionFile = fileSystem.file('/release-candidate-branch.version')..writeAsStringSync(branch);
|
||||
test(
|
||||
'updateCandidateBranchVersion() returns false if branch is the same as version file',
|
||||
() async {
|
||||
const String branch = 'flutter-2.15-candidate.3';
|
||||
final File versionFile = fileSystem.file('/release-candidate-branch.version')
|
||||
..writeAsStringSync(branch);
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final FrameworkRepository repo = FrameworkRepository(checkouts);
|
||||
final bool didUpdate = await repo.updateCandidateBranchVersion(branch, versionFile: versionFile);
|
||||
expect(didUpdate, false);
|
||||
});
|
||||
final FrameworkRepository repo = FrameworkRepository(checkouts);
|
||||
final bool didUpdate = await repo.updateCandidateBranchVersion(
|
||||
branch,
|
||||
versionFile: versionFile,
|
||||
);
|
||||
expect(didUpdate, false);
|
||||
},
|
||||
);
|
||||
|
||||
test('updateEngineRevision() returns false if newCommit is the same as version file', () async {
|
||||
const String commit1 = 'abc123';
|
||||
const String commit2 = 'def456';
|
||||
final File engineVersionFile = fileSystem.file('/engine.version')..writeAsStringSync(commit2);
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit1),
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit1),
|
||||
]);
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
@@ -234,90 +202,88 @@ vars = {
|
||||
);
|
||||
|
||||
final FrameworkRepository repo = FrameworkRepository(checkouts);
|
||||
final bool didUpdate = await repo.updateEngineRevision(commit2, engineVersionFile: engineVersionFile);
|
||||
final bool didUpdate = await repo.updateEngineRevision(
|
||||
commit2,
|
||||
engineVersionFile: engineVersionFile,
|
||||
);
|
||||
expect(didUpdate, false);
|
||||
});
|
||||
|
||||
test('framework repo set as localUpstream ensures requiredLocalBranches exist locally', () async {
|
||||
const String commit = 'deadbeef';
|
||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||
bool createdCandidateBranch = false;
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
]),
|
||||
FakeCommand(
|
||||
command: const <String>['git', 'checkout', candidateBranch, '--'],
|
||||
onRun: (_) => createdCandidateBranch = true,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', 'stable', '--'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', 'beta', '--'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', FrameworkRepository.defaultBranch, '--'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', FrameworkRepository.defaultBranch],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: commit,
|
||||
),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
test(
|
||||
'framework repo set as localUpstream ensures requiredLocalBranches exist locally',
|
||||
() async {
|
||||
const String commit = 'deadbeef';
|
||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||
bool createdCandidateBranch = false;
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
],
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>['git', 'checkout', candidateBranch, '--'],
|
||||
onRun: (_) => createdCandidateBranch = true,
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'checkout', 'stable', '--']),
|
||||
const FakeCommand(command: <String>['git', 'checkout', 'beta', '--']),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', FrameworkRepository.defaultBranch, '--'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', FrameworkRepository.defaultBranch],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final Repository repo = FrameworkRepository(
|
||||
checkouts,
|
||||
additionalRequiredLocalBranches: <String>[candidateBranch],
|
||||
localUpstream: true,
|
||||
);
|
||||
// call this so that repo.lazilyInitialize() is called.
|
||||
await repo.checkoutDirectory;
|
||||
final Repository repo = FrameworkRepository(
|
||||
checkouts,
|
||||
additionalRequiredLocalBranches: <String>[candidateBranch],
|
||||
localUpstream: true,
|
||||
);
|
||||
// call this so that repo.lazilyInitialize() is called.
|
||||
await repo.checkoutDirectory;
|
||||
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
expect(createdCandidateBranch, true);
|
||||
});
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
expect(createdCandidateBranch, true);
|
||||
},
|
||||
);
|
||||
|
||||
test('engine repo set as localUpstream ensures requiredLocalBranches exist locally', () async {
|
||||
const String commit = 'deadbeef';
|
||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||
bool createdCandidateBranch = false;
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
]),
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
],
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>['git', 'checkout', candidateBranch, '--'],
|
||||
onRun: (_) => createdCandidateBranch = true,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'checkout', EngineRepository.defaultBranch],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: commit,
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'checkout', EngineRepository.defaultBranch]),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
@@ -353,25 +319,19 @@ bbbcae73699263764ad4421a4b2ca3952a6f96cb refs/heads/stable
|
||||
Extraneous debug information that should be ignored.
|
||||
''';
|
||||
processManager.addCommands(const <FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
'${rootDir}flutter_conductor_checkouts/engine',
|
||||
]),
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
'main',
|
||||
]),
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: revision),
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
'${rootDir}flutter_conductor_checkouts/engine',
|
||||
],
|
||||
),
|
||||
FakeCommand(command: <String>['git', 'checkout', 'main']),
|
||||
FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: revision),
|
||||
FakeCommand(
|
||||
command: <String>['git', 'ls-remote', '--heads', remoteName],
|
||||
stdout: lsRemoteOutput,
|
||||
@@ -385,18 +345,12 @@ Extraneous debug information that should be ignored.
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final Repository repo = EngineRepository(
|
||||
checkouts,
|
||||
localUpstream: true,
|
||||
);
|
||||
final Repository repo = EngineRepository(checkouts, localUpstream: true);
|
||||
final List<String> branchNames = await repo.listRemoteBranches(remoteName);
|
||||
expect(branchNames, equals(<String>[
|
||||
'experiment',
|
||||
'feature-a',
|
||||
'feature-b',
|
||||
'fix_bug_1234',
|
||||
'stable',
|
||||
]));
|
||||
expect(
|
||||
branchNames,
|
||||
equals(<String>['experiment', 'feature-a', 'feature-b', 'fix_bug_1234', 'stable']),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,31 +12,27 @@ import './common.dart';
|
||||
void main() {
|
||||
test('writeStateToFile() pretty-prints JSON with 2 spaces', () {
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final File stateFile = fileSystem.file('/path/to/statefile.json')
|
||||
..createSync(recursive: true);
|
||||
final File stateFile = fileSystem.file('/path/to/statefile.json')..createSync(recursive: true);
|
||||
const String candidateBranch = 'flutter-2.3-candidate.0';
|
||||
final pb.ConductorState state = pb.ConductorState.create()
|
||||
..releaseChannel = 'stable'
|
||||
..releaseVersion = '2.3.4'
|
||||
..engine = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..upstream = (pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = 'git@github.com:flutter/engine.git'
|
||||
)
|
||||
)
|
||||
..framework = (pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..upstream = (pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = 'git@github.com:flutter/flutter.git'
|
||||
)
|
||||
);
|
||||
writeStateToFile(
|
||||
stateFile,
|
||||
state,
|
||||
<String>['[status] hello world'],
|
||||
);
|
||||
final pb.ConductorState state =
|
||||
pb.ConductorState.create()
|
||||
..releaseChannel = 'stable'
|
||||
..releaseVersion = '2.3.4'
|
||||
..engine =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..upstream =
|
||||
(pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = 'git@github.com:flutter/engine.git'))
|
||||
..framework =
|
||||
(pb.Repository.create()
|
||||
..candidateBranch = candidateBranch
|
||||
..upstream =
|
||||
(pb.Remote.create()
|
||||
..name = 'upstream'
|
||||
..url = 'git@github.com:flutter/flutter.git'));
|
||||
writeStateToFile(stateFile, state, <String>['[status] hello world']);
|
||||
final String serializedState = stateFile.readAsStringSync();
|
||||
const String expectedString = '''
|
||||
{
|
||||
|
||||
@@ -26,80 +26,83 @@ void main() {
|
||||
expect(version.type, VersionType.gitDescribe);
|
||||
});
|
||||
});
|
||||
group('Version.increment()', () {
|
||||
test('throws exception on nonsensical `level`', () {
|
||||
final List<String> levels = <String>['f', '0', 'xyz'];
|
||||
for (final String level in levels) {
|
||||
group(
|
||||
'Version.increment()',
|
||||
() {
|
||||
test('throws exception on nonsensical `level`', () {
|
||||
final List<String> levels = <String>['f', '0', 'xyz'];
|
||||
for (final String level in levels) {
|
||||
final Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(
|
||||
() => Version.increment(version, level).toString(),
|
||||
throwsExceptionWith('Unknown increment level $level.'),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('does not support incrementing x', () {
|
||||
const String level = 'x';
|
||||
|
||||
final Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(
|
||||
() => Version.increment(version, level).toString(),
|
||||
throwsExceptionWith('Unknown increment level $level.'),
|
||||
throwsExceptionWith('Incrementing $level is not supported by this tool'),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('does not support incrementing x', () {
|
||||
const String level = 'x';
|
||||
test('successfully increments y', () {
|
||||
const String level = 'y';
|
||||
|
||||
final Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(
|
||||
() => Version.increment(version, level).toString(),
|
||||
throwsExceptionWith(
|
||||
'Incrementing $level is not supported by this tool'),
|
||||
);
|
||||
});
|
||||
Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.1.0-0.0.pre');
|
||||
|
||||
test('successfully increments y', () {
|
||||
const String level = 'y';
|
||||
version = Version.fromString('10.20.0-40.50.pre');
|
||||
expect(Version.increment(version, level).toString(), '10.21.0-0.0.pre');
|
||||
|
||||
Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.1.0-0.0.pre');
|
||||
version = Version.fromString('1.18.0-3.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.19.0-0.0.pre');
|
||||
});
|
||||
|
||||
version = Version.fromString('10.20.0-40.50.pre');
|
||||
expect(Version.increment(version, level).toString(), '10.21.0-0.0.pre');
|
||||
test('successfully increments z', () {
|
||||
const String level = 'z';
|
||||
|
||||
version = Version.fromString('1.18.0-3.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.19.0-0.0.pre');
|
||||
});
|
||||
Version version = Version.fromString('1.0.0');
|
||||
expect(Version.increment(version, level).toString(), '1.0.1');
|
||||
|
||||
test('successfully increments z', () {
|
||||
const String level = 'z';
|
||||
version = Version.fromString('10.20.0');
|
||||
expect(Version.increment(version, level).toString(), '10.20.1');
|
||||
|
||||
Version version = Version.fromString('1.0.0');
|
||||
expect(Version.increment(version, level).toString(), '1.0.1');
|
||||
version = Version.fromString('1.18.3');
|
||||
expect(Version.increment(version, level).toString(), '1.18.4');
|
||||
});
|
||||
|
||||
version = Version.fromString('10.20.0');
|
||||
expect(Version.increment(version, level).toString(), '10.20.1');
|
||||
test('does not support incrementing m', () {
|
||||
const String level = 'm';
|
||||
|
||||
version = Version.fromString('1.18.3');
|
||||
expect(Version.increment(version, level).toString(), '1.18.4');
|
||||
});
|
||||
final Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(
|
||||
() => Version.increment(version, level).toString(),
|
||||
throwsAssertionWith("Do not increment 'm' via Version.increment"),
|
||||
);
|
||||
});
|
||||
|
||||
test('does not support incrementing m', () {
|
||||
const String level = 'm';
|
||||
test('successfully increments n', () {
|
||||
const String level = 'n';
|
||||
|
||||
final Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(
|
||||
() => Version.increment(version, level).toString(),
|
||||
throwsAssertionWith("Do not increment 'm' via Version.increment"),
|
||||
);
|
||||
});
|
||||
Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.0.0-0.1.pre');
|
||||
|
||||
test('successfully increments n', () {
|
||||
const String level = 'n';
|
||||
version = Version.fromString('10.20.0-40.50.pre');
|
||||
expect(Version.increment(version, level).toString(), '10.20.0-40.51.pre');
|
||||
|
||||
Version version = Version.fromString('1.0.0-0.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.0.0-0.1.pre');
|
||||
|
||||
version = Version.fromString('10.20.0-40.50.pre');
|
||||
expect(Version.increment(version, level).toString(), '10.20.0-40.51.pre');
|
||||
|
||||
version = Version.fromString('1.18.0-3.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.18.0-3.1.pre');
|
||||
});
|
||||
}, onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
});
|
||||
version = Version.fromString('1.18.0-3.0.pre');
|
||||
expect(Version.increment(version, level).toString(), '1.18.0-3.1.pre');
|
||||
});
|
||||
},
|
||||
onPlatform: <String, dynamic>{
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
},
|
||||
);
|
||||
|
||||
group('.ensureValid()', () {
|
||||
test('throws when x does not match', () {
|
||||
@@ -157,9 +160,7 @@ void main() {
|
||||
final Version version = Version.fromString(versionString);
|
||||
expect(
|
||||
() => version.ensureValid(candidateBranch, ReleaseType.STABLE_HOTFIX),
|
||||
throwsExceptionWith(
|
||||
'Candidate branch $candidateBranch does not match the pattern',
|
||||
),
|
||||
throwsExceptionWith('Candidate branch $candidateBranch does not match the pattern'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user