[flutter_conductor] Add candidate branch version to releases (#100781)
This commit is contained in:
parent
48d1372c1c
commit
a3d8026993
@ -196,9 +196,21 @@ class NextContext extends Context {
|
||||
upstreamRemote: upstream,
|
||||
previousCheckoutLocation: state.framework.checkoutPath,
|
||||
);
|
||||
|
||||
stdio.printStatus('Writing candidate branch...');
|
||||
bool needsCommit = await framework.updateCandidateBranchVersion(state.releaseVersion);
|
||||
if (needsCommit) {
|
||||
final String revision = await framework.commit(
|
||||
'Create candidate branch version ${state.engine.candidateBranch} for ${state.releaseChannel}',
|
||||
addFirst: true,
|
||||
);
|
||||
// append to list of cherrypicks so we know a PR is required
|
||||
state.framework.cherrypicks.add(pb.Cherrypick(
|
||||
appliedRevision: revision,
|
||||
state: pb.CherrypickState.COMPLETED,
|
||||
));
|
||||
}
|
||||
stdio.printStatus('Rolling new engine hash $engineRevision to framework checkout...');
|
||||
final bool needsCommit = await framework.updateEngineRevision(engineRevision);
|
||||
needsCommit = await framework.updateEngineRevision(engineRevision);
|
||||
if (needsCommit) {
|
||||
final String revision = await framework.commit(
|
||||
'Update Engine revision to $engineRevision for ${state.releaseChannel} release ${state.releaseVersion}',
|
||||
|
@ -620,6 +620,39 @@ class FrameworkRepository extends Repository {
|
||||
return Version.fromString(versionJson['frameworkVersion'] as String);
|
||||
}
|
||||
|
||||
/// Create a release candidate branch version file.
|
||||
///
|
||||
/// This file allows for easily traversing what candidadate branch was used
|
||||
/// from a release channel.
|
||||
///
|
||||
/// Returns [true] if the version file was updated and a commit is needed.
|
||||
Future<bool> updateCandidateBranchVersion(
|
||||
String branch, {
|
||||
@visibleForTesting File? versionFile,
|
||||
}) async {
|
||||
assert(branch.isNotEmpty);
|
||||
versionFile ??= (await checkoutDirectory)
|
||||
.childDirectory('bin')
|
||||
.childDirectory('internal')
|
||||
.childFile('release-candidate-branch.version');
|
||||
if (versionFile.existsSync()) {
|
||||
final String oldCandidateBranch = versionFile.readAsStringSync();
|
||||
if (oldCandidateBranch.trim() == branch.trim()) {
|
||||
stdio.printTrace(
|
||||
'Tried to update the candidate branch but version file is already up to date at: $branch',
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
stdio.printStatus('Create ${versionFile.path} containing $branch');
|
||||
versionFile.writeAsStringSync(
|
||||
// Version files have trailing newlines
|
||||
'${branch.trim()}\n',
|
||||
flush: true,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Update this framework's engine version file.
|
||||
///
|
||||
/// Returns [true] if the version file was updated and a commit is needed.
|
||||
|
@ -25,6 +25,7 @@ void main() {
|
||||
const String remoteUrl = 'https://github.com/org/repo.git';
|
||||
const String revision1 = 'd3af60d18e01fcb36e0c0fa06c8502e4935ed095';
|
||||
const String revision2 = 'f99555c1e1392bf2a8135056b9446680c2af4ddf';
|
||||
const String revision3 = 'ffffffffffffffffffffffffffffffffffffffff';
|
||||
const String revision4 = '280e23318a0d8341415c66aa32581352a421d974';
|
||||
const String releaseVersion = '1.2.0-3.0.pre';
|
||||
const String releaseChannel = 'beta';
|
||||
@ -495,7 +496,21 @@ void main() {
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM /path/to/engine.version',
|
||||
stdout: 'MM bin/internal/release-candidate-branch.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
"--message='Create candidate branch version $candidateBranch for $releaseChannel'",
|
||||
]),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: revision3,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM bin/internal/engine.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
@ -571,7 +586,21 @@ void main() {
|
||||
const FakeCommand(command: <String>['git', 'checkout', workingBranch]),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM path/to/engine.version',
|
||||
stdout: 'MM bin/internal/release-candidate-branch.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
"--message='Create candidate branch version $candidateBranch for $releaseChannel'",
|
||||
]),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: revision3,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM bin/internal/engine.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
@ -635,7 +664,21 @@ void main() {
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM path/to/.ci.yaml',
|
||||
stdout: 'MM bin/internal/release-candidate-branch.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
"--message='Create candidate branch version $candidateBranch for $releaseChannel'",
|
||||
]),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: revision3,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'status', '--porcelain'],
|
||||
stdout: 'MM bin/internal/engine.version',
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'add', '--all']),
|
||||
const FakeCommand(command: <String>[
|
||||
|
@ -340,6 +340,23 @@ 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);
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
test('updateEngineRevision() returns false if newCommit is the same as version file', () async {
|
||||
const String commit1 = 'abc123';
|
||||
const String commit2 = 'def456';
|
||||
|
Loading…
x
Reference in New Issue
Block a user