[flutter_conductor] ensure release branch point is always tagged (#93082)
This commit is contained in:
parent
4dd56df426
commit
2107fef430
@ -8,6 +8,8 @@ import 'proto/conductor_state.pb.dart' as pb;
|
|||||||
|
|
||||||
const String gsutilBinary = 'gsutil.py';
|
const String gsutilBinary = 'gsutil.py';
|
||||||
|
|
||||||
|
const String kFrameworkDefaultBranch = 'master';
|
||||||
|
|
||||||
const List<String> kReleaseChannels = <String>[
|
const List<String> kReleaseChannels = <String>[
|
||||||
'stable',
|
'stable',
|
||||||
'beta',
|
'beta',
|
||||||
|
@ -362,26 +362,9 @@ class StartContext {
|
|||||||
framework.upstreamRemote.name, candidateBranch,
|
framework.upstreamRemote.name, candidateBranch,
|
||||||
exact: false,
|
exact: false,
|
||||||
))..ensureValid(candidateBranch, incrementLetter);
|
))..ensureValid(candidateBranch, incrementLetter);
|
||||||
Version nextVersion;
|
Version nextVersion = calculateNextVersion(lastVersion);
|
||||||
if (incrementLetter == 'm') {
|
nextVersion = await ensureBranchPointTagged(nextVersion, framework);
|
||||||
nextVersion = Version.fromCandidateBranch(candidateBranch);
|
|
||||||
} else {
|
|
||||||
if (incrementLetter == 'z') {
|
|
||||||
if (lastVersion.type == VersionType.stable) {
|
|
||||||
nextVersion = Version.increment(lastVersion, incrementLetter);
|
|
||||||
} else {
|
|
||||||
// This is the first stable release, so hardcode the z as 0
|
|
||||||
nextVersion = Version(
|
|
||||||
x: lastVersion.x,
|
|
||||||
y: lastVersion.y,
|
|
||||||
z: 0,
|
|
||||||
type: VersionType.stable,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nextVersion = Version.increment(lastVersion, incrementLetter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state.releaseVersion = nextVersion.toString();
|
state.releaseVersion = nextVersion.toString();
|
||||||
|
|
||||||
final String frameworkHead = await framework.reverseParse('HEAD');
|
final String frameworkHead = await framework.reverseParse('HEAD');
|
||||||
@ -417,6 +400,54 @@ class StartContext {
|
|||||||
state_import.writeStateToFile(stateFile, state, logs);
|
state_import.writeStateToFile(stateFile, state, logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determine this release's version number from the [lastVersion] and the [incrementLetter].
|
||||||
|
Version calculateNextVersion(Version lastVersion) {
|
||||||
|
if (incrementLetter == 'm') {
|
||||||
|
return Version.fromCandidateBranch(candidateBranch);
|
||||||
|
}
|
||||||
|
if (incrementLetter == 'z') {
|
||||||
|
if (lastVersion.type == VersionType.stable) {
|
||||||
|
return Version.increment(lastVersion, incrementLetter);
|
||||||
|
}
|
||||||
|
// This is the first stable release, so hardcode the z as 0
|
||||||
|
return Version(
|
||||||
|
x: lastVersion.x,
|
||||||
|
y: lastVersion.y,
|
||||||
|
z: 0,
|
||||||
|
type: VersionType.stable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Version.increment(lastVersion, incrementLetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensures the branch point [candidateBranch] and `master` has a version tag.
|
||||||
|
///
|
||||||
|
/// This is necessary for version reporting for users on the `master` channel
|
||||||
|
/// to be correct.
|
||||||
|
Future<Version> ensureBranchPointTagged(
|
||||||
|
Version requestedVersion,
|
||||||
|
FrameworkRepository framework,
|
||||||
|
) async {
|
||||||
|
if (incrementLetter != 'm') {
|
||||||
|
// in this case, there must have been a previous tagged release, so skip
|
||||||
|
// tagging the branch point
|
||||||
|
return requestedVersion;
|
||||||
|
}
|
||||||
|
final String branchPoint = await framework.branchPoint(
|
||||||
|
candidateBranch,
|
||||||
|
kFrameworkDefaultBranch,
|
||||||
|
);
|
||||||
|
stdio.printStatus('Applying the tag $requestedVersion at the branch point $branchPoint');
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// To minimize merge conflicts, sort the commits by rev-list order.
|
// To minimize merge conflicts, sort the commits by rev-list order.
|
||||||
Future<List<String>> _sortCherrypicks({
|
Future<List<String>> _sortCherrypicks({
|
||||||
required Repository repository,
|
required Repository repository,
|
||||||
|
@ -125,10 +125,14 @@ void main() {
|
|||||||
test('creates state file if provided correct inputs', () async {
|
test('creates state file if provided correct inputs', () async {
|
||||||
const String revision2 = 'def789';
|
const String revision2 = 'def789';
|
||||||
const String revision3 = '123abc';
|
const String revision3 = '123abc';
|
||||||
|
const String branchPointRevision='deadbeef';
|
||||||
const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef';
|
const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef';
|
||||||
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
||||||
const String previousVersion = '1.2.0-1.0.pre';
|
const String previousVersion = '1.2.0-1.0.pre';
|
||||||
const String nextVersion = '1.2.0-3.0.pre';
|
// This is a git tag applied to the branch point, not an actual release
|
||||||
|
const String branchPointTag = '1.2.0-3.0.pre';
|
||||||
|
// This is what this release will be
|
||||||
|
const String nextVersion = '1.2.0-3.1.pre';
|
||||||
const String incrementLevel = 'm';
|
const String incrementLevel = 'm';
|
||||||
|
|
||||||
final Directory engine = fileSystem.directory(checkoutsParentDirectory)
|
final Directory engine = fileSystem.directory(checkoutsParentDirectory)
|
||||||
@ -243,6 +247,16 @@ void main() {
|
|||||||
],
|
],
|
||||||
stdout: '$previousVersion-42-gabc123',
|
stdout: '$previousVersion-42-gabc123',
|
||||||
),
|
),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>['git', 'merge-base', candidateBranch, 'master'],
|
||||||
|
stdout: branchPointRevision,
|
||||||
|
),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>['git', 'tag', branchPointTag, branchPointRevision],
|
||||||
|
),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>['git', 'push', FrameworkRepository.defaultUpstream, branchPointTag],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||||
stdout: revision3,
|
stdout: revision3,
|
||||||
@ -300,6 +314,9 @@ void main() {
|
|||||||
expect(state.currentPhase, ReleasePhase.APPLY_ENGINE_CHERRYPICKS);
|
expect(state.currentPhase, ReleasePhase.APPLY_ENGINE_CHERRYPICKS);
|
||||||
expect(state.conductorVersion, conductorVersion);
|
expect(state.conductorVersion, conductorVersion);
|
||||||
expect(state.incrementLevel, incrementLevel);
|
expect(state.incrementLevel, incrementLevel);
|
||||||
|
expect(stdio.stdout, contains('Applying the tag $branchPointTag at the branch point $branchPointRevision'));
|
||||||
|
expect(stdio.stdout, contains('The actual release will be version $nextVersion'));
|
||||||
|
expect(branchPointTag != nextVersion, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can convert from dev style version to stable version', () async {
|
test('can convert from dev style version to stable version', () async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user