Skip to content

Commit ad936b4

Browse files
[flutter_conductor] Support initial stable release version (#89775)
1 parent ff5dd54 commit ad936b4

File tree

2 files changed

+197
-1
lines changed

2 files changed

+197
-1
lines changed

dev/conductor/lib/start.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,21 @@ class StartCommand extends Command<void> {
315315
if (incrementLetter == 'm') {
316316
nextVersion = Version.fromCandidateBranch(candidateBranch);
317317
} else {
318-
nextVersion = Version.increment(lastVersion, incrementLetter);
318+
if (incrementLetter == 'z') {
319+
if (lastVersion.type == VersionType.stable) {
320+
nextVersion = Version.increment(lastVersion, incrementLetter);
321+
} else {
322+
// This is the first stable release, so hardcode the z as 0
323+
nextVersion = Version(
324+
x: lastVersion.x,
325+
y: lastVersion.y,
326+
z: 0,
327+
type: VersionType.stable,
328+
);
329+
}
330+
} else {
331+
nextVersion = Version.increment(lastVersion, incrementLetter);
332+
}
319333
}
320334
state.releaseVersion = nextVersion.toString();
321335

dev/conductor/test/start_test.dart

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,188 @@ void main() {
289289
expect(state.conductorVersion, revision);
290290
expect(state.incrementLevel, incrementLevel);
291291
});
292+
293+
test('can convert from dev style version to stable version', () async {
294+
const String revision2 = 'def789';
295+
const String revision3 = '123abc';
296+
const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef';
297+
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
298+
const String previousVersion = '1.2.0-1.0.pre';
299+
const String nextVersion = '1.2.0';
300+
const String incrementLevel = 'z';
301+
302+
final Directory engine = fileSystem.directory(checkoutsParentDirectory)
303+
.childDirectory('flutter_conductor_checkouts')
304+
.childDirectory('engine');
305+
306+
final File depsFile = engine.childFile('DEPS');
307+
308+
final List<FakeCommand> engineCommands = <FakeCommand>[
309+
FakeCommand(
310+
command: <String>[
311+
'git',
312+
'clone',
313+
'--origin',
314+
'upstream',
315+
'--',
316+
EngineRepository.defaultUpstream,
317+
engine.path,
318+
],
319+
onRun: () {
320+
// Create the DEPS file which the tool will update
321+
engine.createSync(recursive: true);
322+
depsFile.writeAsStringSync(generateMockDeps(previousDartRevision));
323+
}
324+
),
325+
const FakeCommand(
326+
command: <String>['git', 'remote', 'add', 'mirror', engineMirror],
327+
),
328+
const FakeCommand(
329+
command: <String>['git', 'fetch', 'mirror'],
330+
),
331+
const FakeCommand(
332+
command: <String>['git', 'checkout', 'upstream/$candidateBranch'],
333+
),
334+
const FakeCommand(
335+
command: <String>['git', 'rev-parse', 'HEAD'],
336+
stdout: revision2,
337+
),
338+
const FakeCommand(
339+
command: <String>[
340+
'git',
341+
'checkout',
342+
'-b',
343+
'cherrypicks-$candidateBranch',
344+
],
345+
),
346+
const FakeCommand(
347+
command: <String>['git', 'status', '--porcelain'],
348+
stdout: 'MM path/to/DEPS',
349+
),
350+
const FakeCommand(
351+
command: <String>['git', 'add', '--all'],
352+
),
353+
const FakeCommand(
354+
command: <String>['git', 'commit', "--message='Update Dart SDK to $nextDartRevision'"],
355+
),
356+
const FakeCommand(
357+
command: <String>['git', 'rev-parse', 'HEAD'],
358+
stdout: revision2,
359+
),
360+
const FakeCommand(
361+
command: <String>['git', 'rev-parse', 'HEAD'],
362+
stdout: revision2,
363+
),
364+
];
365+
366+
final List<FakeCommand> frameworkCommands = <FakeCommand>[
367+
FakeCommand(
368+
command: <String>[
369+
'git',
370+
'clone',
371+
'--origin',
372+
'upstream',
373+
'--',
374+
FrameworkRepository.defaultUpstream,
375+
fileSystem.path.join(
376+
checkoutsParentDirectory,
377+
'flutter_conductor_checkouts',
378+
'framework',
379+
),
380+
],
381+
),
382+
const FakeCommand(
383+
command: <String>['git', 'remote', 'add', 'mirror', frameworkMirror],
384+
),
385+
const FakeCommand(
386+
command: <String>['git', 'fetch', 'mirror'],
387+
),
388+
const FakeCommand(
389+
command: <String>['git', 'checkout', 'upstream/$candidateBranch'],
390+
),
391+
const FakeCommand(
392+
command: <String>['git', 'rev-parse', 'HEAD'],
393+
stdout: revision3,
394+
),
395+
const FakeCommand(
396+
command: <String>[
397+
'git',
398+
'checkout',
399+
'-b',
400+
'cherrypicks-$candidateBranch',
401+
],
402+
),
403+
const FakeCommand(
404+
command: <String>[
405+
'git',
406+
'describe',
407+
'--match',
408+
'*.*.*',
409+
'--tags',
410+
'refs/remotes/upstream/$candidateBranch',
411+
],
412+
stdout: '$previousVersion-42-gabc123',
413+
),
414+
const FakeCommand(
415+
command: <String>['git', 'rev-parse', 'HEAD'],
416+
stdout: revision3,
417+
),
418+
];
419+
420+
final CommandRunner<void> runner = createRunner(
421+
commands: <FakeCommand>[
422+
const FakeCommand(
423+
command: <String>['git', 'rev-parse', 'HEAD'],
424+
stdout: revision,
425+
),
426+
...engineCommands,
427+
...frameworkCommands,
428+
],
429+
);
430+
431+
final String stateFilePath = fileSystem.path.join(
432+
platform.environment['HOME']!,
433+
kStateFileName,
434+
);
435+
436+
await runner.run(<String>[
437+
'start',
438+
'--$kFrameworkMirrorOption',
439+
frameworkMirror,
440+
'--$kEngineMirrorOption',
441+
engineMirror,
442+
'--$kCandidateOption',
443+
candidateBranch,
444+
'--$kReleaseOption',
445+
releaseChannel,
446+
'--$kStateOption',
447+
stateFilePath,
448+
'--$kDartRevisionOption',
449+
nextDartRevision,
450+
'--$kIncrementOption',
451+
incrementLevel,
452+
]);
453+
454+
final File stateFile = fileSystem.file(stateFilePath);
455+
456+
final pb.ConductorState state = pb.ConductorState();
457+
state.mergeFromProto3Json(
458+
jsonDecode(stateFile.readAsStringSync()),
459+
);
460+
461+
expect(processManager.hasRemainingExpectations, false);
462+
expect(state.isInitialized(), true);
463+
expect(state.releaseChannel, releaseChannel);
464+
expect(state.releaseVersion, nextVersion);
465+
expect(state.engine.candidateBranch, candidateBranch);
466+
expect(state.engine.startingGitHead, revision2);
467+
expect(state.engine.dartRevision, nextDartRevision);
468+
expect(state.framework.candidateBranch, candidateBranch);
469+
expect(state.framework.startingGitHead, revision3);
470+
expect(state.currentPhase, ReleasePhase.APPLY_ENGINE_CHERRYPICKS);
471+
expect(state.conductorVersion, revision);
472+
expect(state.incrementLevel, incrementLevel);
473+
});
292474
}, onPlatform: <String, dynamic>{
293475
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
294476
});

0 commit comments

Comments
 (0)