-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update release instructions and clean up update deps helper (#6320)
- Loading branch information
1 parent
7100e3f
commit a6de07d
Showing
10 changed files
with
260 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright 2023 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:args/command_runner.dart'; | ||
import 'package:io/io.dart'; | ||
import 'package:path/path.dart' as path; | ||
|
||
import '../utils.dart'; | ||
|
||
const _argCommit = 'commit'; | ||
|
||
/// This command updates the "devtools_rev" hash in the Dart SDK DEPS file with | ||
/// the provided commit hash, and creates a Gerrit CL for review. | ||
/// | ||
/// This hash is the ID for a DevTools build stored in CIPD, which is | ||
/// automatically built and uploaded to CIPD on each DevTools commit. | ||
/// | ||
/// To run this script: | ||
/// `dart run tool/bin/devtools_tool.dart update-sdk-deps -c <commit-hash>` | ||
class UpdateDartSdkDepsCommand extends Command { | ||
UpdateDartSdkDepsCommand() { | ||
argParser.addOption( | ||
_argCommit, | ||
abbr: 'c', | ||
help: 'The DevTools commit hash to release into the Dart SDK.', | ||
mandatory: true, | ||
); | ||
} | ||
@override | ||
String get name => 'update-sdk-deps'; | ||
|
||
@override | ||
String get description => | ||
'Updates the "devtools_rev" hash in the Dart SDK DEPS file with the ' | ||
'provided commit hash, and creates a Gerrit CL for review'; | ||
|
||
@override | ||
Future run() async { | ||
final commit = argResults![_argCommit]; | ||
final dartSdkLocation = localDartSdkLocation(); | ||
final processManager = ProcessManager(); | ||
|
||
print('Preparing a local Dart SDK branch...'); | ||
await DartSdkHelper.fetchAndCheckoutMaster(processManager); | ||
await runAll( | ||
processManager, | ||
workingDirectory: dartSdkLocation, | ||
additionalErrorMessage: DartSdkHelper.commandDebugMessage, | ||
commands: [ | ||
CliCommand( | ||
'git branch -D devtools-$commit', | ||
throwOnException: false, | ||
), | ||
CliCommand('git new-branch devtools-$commit'), | ||
], | ||
); | ||
|
||
print('Updating the DEPS file with the new DevTools hash...'); | ||
_writeToDepsFile(commit, dartSdkLocation); | ||
|
||
print('Committing the changes and creating a Gerrit CL...'); | ||
await runAll( | ||
processManager, | ||
workingDirectory: dartSdkLocation, | ||
additionalErrorMessage: DartSdkHelper.commandDebugMessage, | ||
commands: [ | ||
CliCommand('git add .'), | ||
CliCommand.from( | ||
'git', | ||
[ | ||
'commit', | ||
'-m', | ||
'Update DevTools rev to $commit', | ||
], | ||
), | ||
// TODO(kenz): is there a way to automatically close the file that pops up | ||
// with the commit description? | ||
CliCommand('git cl upload -s'), | ||
], | ||
); | ||
|
||
// Closes stdin for the entire program. | ||
await sharedStdIn.terminate(); | ||
} | ||
|
||
void _writeToDepsFile(String commit, String localDartSdkLocation) { | ||
final depsFilePath = path.join(localDartSdkLocation, 'DEPS'); | ||
final depsFile = File(depsFilePath); | ||
if (!depsFile.existsSync()) { | ||
throw Exception('Count not find SDK DEPS file at: $depsFilePath'); | ||
} | ||
|
||
final devToolsRevMarker = ' "devtools_rev":'; | ||
final newFileContent = StringBuffer(); | ||
final lines = depsFile.readAsLinesSync(); | ||
for (final line in lines) { | ||
if (line.startsWith(devToolsRevMarker)) { | ||
newFileContent.writeln('$devToolsRevMarker "$commit",'); | ||
} else { | ||
newFileContent.writeln(line); | ||
} | ||
} | ||
depsFile.writeAsStringSync(newFileContent.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.