feat: teach cutler that Dart exists (#579)

This commit is contained in:
Eric Seidel
2023-06-01 17:35:22 -04:00
committed by GitHub
parent b8da256b5e
commit 75c1725a69
4 changed files with 61 additions and 12 deletions
@@ -106,8 +106,10 @@ class RebaseCommand extends CutlerCommand {
}
// Rebase our repos.
// These are done in a very specific order.
var newHead = VersionSet(
buildroot: doRebase(Repo.buildroot),
dart: doRebase(Repo.dart),
engine: doRebase(Repo.engine),
flutter: doRebase(Repo.flutter),
);
+20 -1
View File
@@ -26,6 +26,14 @@ enum Repo {
upstreamBranch: 'upstream/master',
),
/// Repo configuration representing the dart-lang/sdk repo.
dart(
name: 'dart',
path: 'engine/src/third_party/dart',
url: 'https://github.com/shorebirdtech/dart-sdk.git',
upstreamBranch: 'upstream/master',
),
/// Repo configuration representing the buildroot repo.
buildroot(
name: 'buildroot',
@@ -120,6 +128,7 @@ class VersionSet {
required this.engine,
required this.flutter,
required this.buildroot,
required this.dart,
});
/// The engine version.
@@ -128,6 +137,9 @@ class VersionSet {
/// The flutter version.
final Version flutter;
/// The dart version.
final Version dart;
/// The buildroot version.
final Version buildroot;
@@ -136,14 +148,21 @@ class VersionSet {
Repo.engine: engine,
Repo.flutter: flutter,
Repo.buildroot: buildroot,
Repo.dart: dart,
}[repo]!;
/// Copies the VersionSet replacing any provided values.
VersionSet copyWith({Version? engine, Version? flutter, Version? buildroot}) {
VersionSet copyWith({
Version? engine,
Version? flutter,
Version? buildroot,
Version? dart,
}) {
return VersionSet(
engine: engine ?? this.engine,
flutter: flutter ?? this.flutter,
buildroot: buildroot ?? this.buildroot,
dart: dart ?? this.dart,
);
}
}
+31 -8
View File
@@ -3,9 +3,15 @@ import 'package:cutler/model.dart';
/// Print VersionSet [versions] to stdout at a given [indent] level.
void printVersions(VersionSet versions, {int indent = 0}) {
print("${' ' * indent}flutter ${versions.flutter}");
print("${' ' * indent}engine ${versions.engine}");
print("${' ' * indent}buildroot ${versions.buildroot}");
final repos = [
Repo.flutter,
Repo.engine,
Repo.dart,
Repo.buildroot,
];
for (final repo in repos) {
print("${' ' * indent}${repo.name.padRight(9)} ${versions[repo]}");
}
}
/// Returns a [VersionSet] for Flutter for a given [flutterHash].
@@ -18,16 +24,18 @@ VersionSet getFlutterVersions(String flutterHash) {
.trim();
final depsContents =
Repo.engine.contentsAtPath(engineHash, Paths.engineDEPS.path);
final buildrootVersion = parseBuildRoot(depsContents);
final buildrootHash = parseBuildrootRevision(depsContents);
final dartHash = parseDartRevision(depsContents);
return VersionSet(
engine: Repo.engine.versionFrom(engineHash),
flutter: Repo.flutter.versionFrom(flutterHash),
buildroot: Repo.buildroot.versionFrom(buildrootVersion),
buildroot: Repo.buildroot.versionFrom(buildrootHash),
dart: Repo.dart.versionFrom(dartHash),
);
}
/// Parses the given DEPS file contents and returns the buildroot version.
String parseBuildRoot(String depsContents) {
/// Parses the given DEPS file contents and returns the buildroot revision.
String parseBuildrootRevision(String depsContents) {
final lines = depsContents.split('\n');
// Example:
// 'src': 'https://github.com/flutter/buildroot.git' + '@' + '059d155b4d452efd9c4427c45cddfd9445144869',
@@ -35,7 +43,22 @@ String parseBuildRoot(String depsContents) {
final regexp = RegExp('([0-9a-f]{40})');
final match = regexp.firstMatch(buildrootLine);
if (match == null) {
throw Exception('Failed to parse buildroot version from $buildrootLine');
throw Exception('Failed to parse buildroot revision from $buildrootLine');
}
return match.group(0)!;
}
/// Parses the given DEPS file contents and returns the dart-lang/sdk revision.
String parseDartRevision(String depsContents) {
final lines = depsContents.split('\n');
// Example:
// 'dart_revision': 'ce926bc6dcf649bd31a396e4e3961196115727cd',
final dartLine =
lines.firstWhere((line) => line.contains("'dart_revision': "));
final regexp = RegExp('([0-9a-f]{40})');
final match = regexp.firstMatch(dartLine);
if (match == null) {
throw Exception('Failed to parse dart revision from $dartLine');
}
return match.group(0)!;
}
+8 -3
View File
@@ -5,10 +5,15 @@ import 'package:cutler/versions.dart';
import 'package:test/test.dart';
void main() {
test('parseBuildRoot', () {
test('parseBuildrootVersion', () {
final depsContents = File('test/fixtures/DEPS').readAsStringSync();
final buildrootVersion = parseBuildRoot(depsContents);
expect(buildrootVersion, 'd6c410f19de5947de40ce110c1e768c887870072');
final buildrootHash = parseBuildrootRevision(depsContents);
expect(buildrootHash, 'd6c410f19de5947de40ce110c1e768c887870072');
});
test('parseDartVersion', () {
final depsContents = File('test/fixtures/DEPS').readAsStringSync();
final dartHash = parseDartRevision(depsContents);
expect(dartHash, '7a6514d1377175decd3a886fe4190fbbebddac3a');
});
test('expandUser', () {
final path = expandUser('~/foo/bar', env: {'HOME': '/home/user'});