Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: tools/apps/update_homebrew/bin/update_homebrew.dart

Issue 1170973002: update_homebrew: more fixes (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: method renaming Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/apps/update_homebrew/bin/update_homebrew.dart
diff --git a/tools/apps/update_homebrew/bin/update_homebrew.dart b/tools/apps/update_homebrew/bin/update_homebrew.dart
index 7e21db92645214140f3be747d569a7f1da9690b7..dbb62f85e840df89bf2fce822343edc4fc3d4bc3 100644
--- a/tools/apps/update_homebrew/bin/update_homebrew.dart
+++ b/tools/apps/update_homebrew/bin/update_homebrew.dart
@@ -21,17 +21,13 @@ const GITHUB_REPO = 'dart-lang/homebrew-dart';
const CHANNELS = const ['dev', 'stable'];
-const SDK_FILES = const [
- 'sdk/dartsdk-macos-x64-release.zip',
- 'sdk/dartsdk-macos-ia32-release.zip'
-];
+const FILES = const [x64File, ia32File, dartiumFile, contentShellFile];
-const DARTIUM_FILES = const [
- 'dartium/dartium-macos-ia32-release.zip',
- 'dartium/content_shell-macos-ia32-release.zip'
-];
-
-final FILES = []..addAll(SDK_FILES)..addAll(DARTIUM_FILES);
+const urlBase = 'https://storage.googleapis.com/dart-archive/channels';
+const x64File = 'sdk/dartsdk-macos-x64-release.zip';
+const ia32File = 'sdk/dartsdk-macos-ia32-release.zip';
+const dartiumFile = 'dartium/dartium-macos-ia32-release.zip';
+const contentShellFile = 'dartium/content_shell-macos-ia32-release.zip';
Future<String> getHash256(
String channel, String revision, String download) async {
@@ -65,7 +61,8 @@ Future<String> getVersion(String channel, String revision) async {
}
}
-Future setCurrentRevisions(Map revisions) async {
+Future<Map> getCurrentRevisions() async {
+ var revisions = <String, String>{};
var lines = await (new File('$repository/dart.rb')).readAsLines();
for (var channel in CHANNELS) {
@@ -82,50 +79,44 @@ Future setCurrentRevisions(Map revisions) async {
revisions[channel] =
regExp.firstMatch(lines.firstWhere(regExp.hasMatch)).group(1);
}
+ return revisions;
}
-Future setHashes(Map revisions, Map hashes) {
- List waitOn = [];
+Future<Map> getHashes(Map revisions) async {
+ var hashes = <String, Map>{};
for (var channel in CHANNELS) {
hashes[channel] = {};
for (var file in FILES) {
- waitOn.add(getHash256(channel, revisions[channel], file).then((hash) {
- hashes[channel][file] = hash;
- }));
+ var hash = await getHash256(channel, revisions[channel], file);
+ hashes[channel][file] = hash;
}
}
- return Future.wait(waitOn);
+ return hashes;
}
Future writeHomebrewInfo(String channel, String revision) async {
- var revisions = {};
- var hashes = {};
-
- await setCurrentRevisions(revisions);
+ var revisions = await getCurrentRevisions();
if (revisions[channel] == revision) {
print("Channel $channel is already at revision $revision in homebrew.");
exit(0);
}
revisions[channel] = revision;
- await setHashes(revisions, hashes);
+ var hashes = await getHashes(revisions);
var devVersion = await getVersion('dev', revisions['dev']);
var stableVersion = await getVersion('stable', revisions['stable']);
- await (new File('$repository/dartium.rb').openWrite()
- ..write(DartiumFile(revisions, hashes, devVersion, stableVersion))).close();
- await (new File('$repository/dart.rb').openWrite()
- ..write(DartFile(revisions, hashes, devVersion, stableVersion))).close();
+ await new File('$repository/dartium.rb').writeAsString(
+ createDartiumFormula(revisions, hashes, devVersion, stableVersion),
+ flush: true);
+ await new File('$repository/dart.rb').writeAsString(
+ createDartFormula(revisions, hashes, devVersion, stableVersion),
+ flush: true);
}
-String DartiumFile(
- Map revisions, Map hashes, String devVersion, String stableVersion) {
- final urlBase = 'https://storage.googleapis.com/dart-archive/channels';
- final dartiumFile = 'dartium/dartium-macos-ia32-release.zip';
- final contentShellFile = 'dartium/content_shell-macos-ia32-release.zip';
-
- return '''
+String createDartiumFormula(
+ Map revisions, Map hashes, String devVersion, String stableVersion) => '''
require 'formula'
class Dartium < Formula
@@ -181,15 +172,9 @@ class Dartium < Formula
end
end
''';
-}
-
-String DartFile(
- Map revisions, Map hashes, String devVersion, String stableVersion) {
- final urlBase = 'https://storage.googleapis.com/dart-archive/channels';
- final x64File = 'sdk/dartsdk-macos-x64-release.zip';
- final ia32File = 'sdk/dartsdk-macos-ia32-release.zip';
- return '''
+String createDartFormula(
+ Map revisions, Map hashes, String devVersion, String stableVersion) => '''
require 'formula'
class Dart < Formula
@@ -238,7 +223,6 @@ class Dart < Formula
end
end
''';
-}
Future runGit(List<String> args) async {
print("git ${args.join(' ')}");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698