super cleanup
diff --git a/tool/lib/commands/release_helper.dart b/tool/lib/commands/release_helper.dart
index 4b0c639..01bce14 100644
--- a/tool/lib/commands/release_helper.dart
+++ b/tool/lib/commands/release_helper.dart
@@ -15,11 +15,9 @@
);
}
@override
- // TODO: implement description
- String get description => 'Creates a draft PR for ';
+ String get description => 'Creates a release version of devtools from the master branch, and pushes up a draft PR.';
@override
- // TODO: implement name
String get name => 'release-helper';
@override
@@ -33,10 +31,8 @@
final initialBranch = currentBranchResult.stdout.toString().trim();
String? cleanBranch;
String? releaseBranch;
- try {
-// #!/bin/bash -e
-// DEVTOOLS_REMOTE=$(git remote -v | grep "flutter/devtools.git" | grep "(fetch)"| tail -n1 | cut -w -f1)
+ try {
// Change the CWD to the repo root
Directory.current = pathFromRepoRoot("");
@@ -48,10 +44,7 @@
);
final remoteRegexpResults = remoteRegexp.allMatches(devtoolsRemotes);
final RegExpMatch devtoolsRemoteResult;
-// if [ -z "$DEVTOOLS_REMOTE" ] ; then
-// echo "Couldn't find a remote that points to flutter/devtools.git"
-// exit 1
-// fi
+
try {
devtoolsRemoteResult = remoteRegexpResults.firstWhere((element) =>
RegExp(r'flutter/devtools.git$')
@@ -61,26 +54,17 @@
}
final remoteOrigin = devtoolsRemoteResult.namedGroup('remote')!;
-// STATUS=$(git status -s)
-// if [[ ! -z "$STATUS" ]] ; then
-// echo "Make sure your working directory is clean before running the helper"
-// exit 1
-// fi
final gitStatusResult =
await DevtoolsProcess.runOrThrow('git', ['status', '-s']);
if (gitStatusResult.stdout.isNotEmpty) {
throw "Error: Make sure your working directory is clean before running the helper";
}
-// echo "Getting a fresh copy of master"
-// echo
-// MASTER="tmp_master_$(date +%s)"
-// git fetch $DEVTOOLS_REMOTE master
-// git checkout -b $MASTER $DEVTOOLS_REMOTE/master
cleanBranch =
'_release_helper_master_${DateTime.now().millisecondsSinceEpoch}';
if (!useCurrentBranch) {
+ print("Getting a fresh copy of master");
await DevtoolsProcess.runOrThrow(
'git', ['fetch', remoteOrigin, 'master']);
@@ -92,23 +76,17 @@
]);
}
-// RELEASE_BRANCH="clean_release_$(date +%s)"
-// git checkout -b "$RELEASE_BRANCH"
releaseBranch =
'_release_helper_release_${DateTime.now().millisecondsSinceEpoch}';
await DevtoolsProcess.runOrThrow(
'git', ['checkout', '-b', releaseBranch]);
-// echo "Ensuring ./tool packages are ready"
-// echo
-// dart pub get
- print(pathFromRepoRoot("tool"));
+ print("Ensuring ./tool packages are ready");
Directory.current = pathFromRepoRoot("tool");
await DevtoolsProcess.runOrThrow('dart', ['pub', 'get']);
Directory.current = pathFromRepoRoot("");
-// ORIGINAL_VERSION=$(dart tool/update_version.dart current-version)
final currentVersionResult =
await DevtoolsProcess.runOrThrow('devtools_tool', [
'update-version',
@@ -117,9 +95,7 @@
final originalVersion = currentVersionResult.stdout;
-// echo "Setting the release version"
-// echo
-// dart tool/update_version.dart auto --type release
+ print( "Setting the release version");
await DevtoolsProcess.runOrThrow('devtools_tool', [
'update-version',
'auto',
@@ -127,7 +103,6 @@
'release',
]);
-// NEW_VERSION=$(dart tool/update_version.dart current-version)
final getNewVersionResult =
await DevtoolsProcess.runOrThrow('devtools_tool', [
'update-version',
@@ -136,11 +111,8 @@
final newVersion = getNewVersionResult.stdout;
-// COMMIT_MESSAGE="Releasing from $ORIGINAL_VERSION to $NEW_VERSION"
final commitMessage = "Releasing from $originalVersion to $newVersion";
-// # Stage the file, commit and push
-// git commit -a -m "$COMMIT_MESSAGE"
await DevtoolsProcess.runOrThrow('git', [
'commit',
'-a',
@@ -148,7 +120,6 @@
commitMessage,
]);
-// git push -u $DEVTOOLS_REMOTE $RELEASE_BRANCH
await DevtoolsProcess.runOrThrow('git', [
'push',
'-u',
@@ -156,10 +127,7 @@
releaseBranch,
]);
-// echo "$0: Creating the PR"
-// echo
print('Creating the PR');
-// PR_URL=$(gh pr create --repo flutter/devtools --draft --title "$COMMIT_MESSAGE" --fill)
final createPRResult = await DevtoolsProcess.runOrThrow('gh', [
'pr',
'create',
@@ -173,9 +141,7 @@
final prURL = createPRResult.stdout;
-// echo "$0: Updating your flutter version to the most recent candidate."
-// echo
-// ./tool/update_flutter_sdk.sh --local
+ print("Updating your flutter version to the most recent candidate.");
await DevtoolsProcess.runOrThrow(
path
.join(
@@ -186,20 +152,15 @@
.toString(),
['--local']);
-// echo "$0: Your Draft release PR can be found at: $PR_URL"
-// echo
-// echo "$0: DONE.
-// echo "$0: Build, run and test this release using: 'dart ./tool/build_e2e.dart'"
print('Your Draft release PR can be found at: $prURL');
print('DONE');
print(
'Build, run and test this release using: `dart ./tool/build_e2e.dart`',
);
- } catch (_) {
+ } finally {
// try to bring the caller back to their original branch if we have failed
await Process.run('git', ['checkout', initialBranch]);
- rethrow;
- } finally {
+
// Try to clean up the temporary branches we made
if (cleanBranch != null) {
await Process.run('git', [