feat: teach cutler about Flutter channels (#454)

This commit is contained in:
Eric Seidel
2023-05-09 15:54:30 -04:00
committed by GitHub
parent a66db40bce
commit 192f77f35a
6 changed files with 83 additions and 41 deletions
@@ -4,7 +4,7 @@ import 'package:artifact_proxy/artifact_proxy.dart';
import 'package:artifact_proxy/config.dart';
import 'package:shelf/shelf.dart';
const String explainerHtml = """
const String _explainerHtml = """
<html>
<head>
<title>Shorebird Artifact Proxy</title>
@@ -40,7 +40,10 @@ Handler artifactProxyHandler({required ArtifactManifestClient client}) {
return (Request request) async {
final path = request.url.path;
if (path.isEmpty) {
return Response.ok(explainerHtml, headers: {'content-type': 'text/html'});
return Response.ok(
_explainerHtml,
headers: {'content-type': 'text/html'},
);
}
RegExpMatch? engineArtifactMatch;
+51 -1
View File
@@ -3,4 +3,54 @@ A tool for managing our fork of Flutter
"Someone who makes or sells cutlery is a cutler." - Wikipedia
"Forks are considered cutlery, right?" - Me
"Forks are considered cutlery, right?" - Me
## Usage
Typical usage:
```
dart run cutler --root=$HOME/Documents/GitHub --dry-run
```
If you're running `cutler` repeatedly, you might also use `--no-update` after
the first run to avoid waiting to try and update git repos.
You can also see what the current stable changes would look like applied to
another Flutter channel with `--flutter-channel`, e.g.:
```
dart run cutler --root=$HOME/Documents/GitHub --dry-run --flutter-channel=beta
```
`--dry-run` will show you the changes it plans to make. Actually making the
changes might work, but hasn't been tested yet.
Example invocation, exploring porting a 3.7.12 based fork onto 3.10 (beta):
```
% dart run cutler --root=$HOME/Documents/GitHub --dry-run --no-update --flutter-channel=beta
Building package executable...
Built cutler:cutler.
Shorebird stable:
flutter 83305b5088e6fe327fb3334a73ff190828d85713
engine c415419390e4751ddfa3110e0808e7abb3d45a18
buildroot 7383548fa2306b5d53979ac5e9d176b35258811b
Forkpoints:
flutter 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf (3.7.12)
engine 1a65d409c7a1438a34d21b60bf30a6fd5db59314 (3.7.12)
buildroot 8747bce41d0dc6d9dc45c4d1b46d2100bb9ee688
Upstream beta:
flutter b1c77b7ed32346fe829c0ca97bd85d19290d54ae (3.10.0-1.5.pre)
engine 50e509c2bd0d7788feb675e38321cc5711c8d2d6 (3.10.0-1.5.pre)
buildroot f24f62fa5381c0e415b6ca2000600fc0600c11c8
Rebasing buildroot...
git rebase --onto f24f62fa5381c0e415b6ca2000600fc0600c11c8 8747bce41d0dc6d9dc45c4d1b46d2100bb9ee688 7383548fa2306b5d53979ac5e9d176b35258811b
Rebasing engine...
git rebase --onto 3.10.0-1.5.pre 3.7.12 c415419390e4751ddfa3110e0808e7abb3d45a18
Rebasing flutter...
git rebase --onto 3.10.0-1.5.pre 3.7.12 83305b5088e6fe327fb3334a73ff190828d85713
Updating engine DEPS...
Would have changed DEPS lines:
( 'src': 'https://github.com/shorebirdtech/buildroot.git' + '@' + 'new-buildroot-hash',)
Updating shorebird flutter version...
Change flutter.version: new-flutter-hash from 83305b5088e6fe327fb3334a73ff190828d85713
```
+17 -31
View File
@@ -76,10 +76,10 @@ extension RepoCommands on Repo {
return output.split('\n');
}
Version getForkPoint() {
Version getForkPoint(String forkBranch) {
final hash = runCommand(
'git',
['merge-base', '--fork-point', upstreamBranch, releaseBranch],
['merge-base', '--fork-point', upstreamBranch, forkBranch],
workingDirectory: _workingDirectory,
);
return versionFrom(hash);
@@ -131,8 +131,8 @@ String printLatestForBranch(Repo repo, String branch) {
}
void printVersions(VersionSet versions, int indent) {
print("${' ' * indent}engine ${versions.engine}");
print("${' ' * indent}flutter ${versions.flutter}");
print("${' ' * indent}engine ${versions.engine}");
print("${' ' * indent}buildroot ${versions.buildroot}");
}
@@ -163,24 +163,6 @@ String parseBuildRoot(String depsContents) {
return match.group(0)!;
}
VersionSet getForkpoints() {
final flutterForkpoint = Repo.flutter.getForkPoint();
// final engineForkpoint = Repo.engine.getForkPoint();
// final buildrootForkpoint = Repo.buildroot.getForkPoint();
// return VersionSet(
// engine: engineForkpoint,
// flutter: flutterForkpoint,
// buildroot: buildrootForkpoint,
// );
// This is slightly error-prone in that we're assuming that our engine and
// buildroot forks started from the correct commit. But I'm not sure how
// to determine the forkpoint otherwise. engine and buildroot don't have
// a stable branch, yet they do seem to "branch" for stable releases at the
// x.x.0 release.
return getFlutterVersions(flutterForkpoint.hash);
}
/// Generate rebase commands for the repo given the version sets.
String rebaseRepo(
Repo repo, {
@@ -216,6 +198,7 @@ String rebaseRepo(
void main(List<String> args) {
config = parseArgs(args);
if (config.doUpdate) {
print('Updating checkouts (use --no-update to skip)');
for (final repo in Repo.values) {
print('Updating ${repo.name}...');
runCommand(
@@ -231,27 +214,30 @@ void main(List<String> args) {
// printLatestForBranch(repo, repo.releaseBranch);
// }
// FIXME: This is wrong, but 0.0.7 doesn't have a flutter.version file yet.
final shorebirdFlutter =
Repo.flutter.getLatestCommit(Repo.flutter.releaseBranch);
// final shorebirdStable =
// Repo.shorebird.getLatestCommit(Repo.shorebird.releaseBranch);
// final shorebirdFlutter = Repo.flutter
// .contentsAtPath(shorebirdStable, 'bin/internal/flutter.version');
final shorebirdStable =
Repo.shorebird.getLatestCommit(config.shorebirdReleaseBranch);
final shorebirdFlutter = Repo.shorebird
.contentsAtPath(shorebirdStable, 'bin/internal/flutter.version');
final shorebird = getFlutterVersions(shorebirdFlutter);
print('Shorebird stable:');
printVersions(shorebird, 2);
final forkpoints = getForkpoints();
final flutterForkpoint = Repo.flutter.getForkPoint(shorebird.flutter.hash);
// This is slightly error-prone in that we're assuming that our engine and
// buildroot forks started from the correct commit. But I'm not sure how
// to determine the forkpoint otherwise. engine and buildroot don't have
// a stable branch, yet they do seem to "branch" for stable releases at the
// x.x.0 release.
final forkpoints = getFlutterVersions(flutterForkpoint.hash);
print('Forkpoints:');
printVersions(forkpoints, 2);
// Figure out the latest version of Flutter.
final upstreamFlutter =
Repo.flutter.getLatestCommit(Repo.flutter.upstreamBranch);
Repo.flutter.getLatestCommit('upstream/${config.flutterChannel}');
// Figure out what versions that Flutter depends on.
final upstream = getFlutterVersions(upstreamFlutter);
print('Upstream stable:');
print('Upstream ${config.flutterChannel}:');
printVersions(upstream, 2);
Version doRebase(Repo repo) {
+10
View File
@@ -27,11 +27,15 @@ class Config {
required this.verbose,
required this.dryRun,
required this.doUpdate,
required this.flutterChannel,
});
final String checkoutsRoot;
final bool verbose;
final bool dryRun;
final bool doUpdate;
final String flutterChannel;
final String shorebirdReleaseBranch = 'origin/stable';
}
late final Config config;
@@ -44,6 +48,11 @@ Config parseArgs(List<String> args) {
defaultsTo: '.',
help: 'Directory in which to find checkouts.',
)
..addOption(
'flutter-channel',
defaultsTo: 'stable',
help: 'Upstream channel to propose rebasing onto.',
)
..addFlag('dry-run', defaultsTo: true, help: 'Do not actually run git.')
..addFlag('update', defaultsTo: true, help: 'Update checkouts.');
final results = parser.parse(args);
@@ -52,5 +61,6 @@ Config parseArgs(List<String> args) {
checkoutsRoot: expandUser(results['root'] as String),
dryRun: results['dry-run'] as bool,
doUpdate: results['update'] as bool,
flutterChannel: results['flutter-channel'] as String,
);
}
-6
View File
@@ -5,28 +5,24 @@ enum Repo {
name: 'shorebird',
path: '_shorebird/shorebird',
url: 'https://github.com/shorebirdtech/shorebird.git',
releaseBranch: 'origin/stable',
upstreamBranch: 'origin/main',
),
flutter(
name: 'flutter',
path: 'flutter',
url: 'https://github.com/shorebirdtech/flutter.git',
releaseBranch: 'origin/stable',
upstreamBranch: 'upstream/stable',
),
engine(
name: 'engine',
path: 'engine/src/flutter',
url: 'https://github.com/shorebirdtech/engine.git',
releaseBranch: 'origin/stable_codepush',
upstreamBranch: 'upstream/master',
),
buildroot(
name: 'buildroot',
path: 'engine/src',
url: 'https://github.com/shorebirdtech/builddoor.git',
releaseBranch: 'origin/stable_codepush',
upstreamBranch: 'upstream/master',
);
@@ -34,14 +30,12 @@ enum Repo {
required this.name,
required this.path,
required this.url,
required this.releaseBranch,
required this.upstreamBranch,
});
final String name;
final String path;
final String url;
final String releaseBranch;
final String upstreamBranch;
}
@@ -30,7 +30,6 @@ class DeleteReleasesCommand extends ShorebirdCommand
'flavor',
help: 'The product flavor to use when deleting releases.',
);
;
}
@override