OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library update_homebrew; | 5 library update_homebrew; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
(...skipping 28 matching lines...) Expand all Loading... |
39 var client = new http.Client(); | 39 var client = new http.Client(); |
40 var api = new storage.StorageApi(client); | 40 var api = new storage.StorageApi(client); |
41 return api.objects.get('dart-archive', | 41 return api.objects.get('dart-archive', |
42 'channels/$channel/release/$revision/VERSION', | 42 'channels/$channel/release/$revision/VERSION', |
43 downloadOptions: DownloadOptions.FullMedia) | 43 downloadOptions: DownloadOptions.FullMedia) |
44 .then((Media media) => JSON.fuse(ASCII).decoder.bind(media.stream).first) | 44 .then((Media media) => JSON.fuse(ASCII).decoder.bind(media.stream).first) |
45 .then((versionObject) => versionObject['version']) | 45 .then((versionObject) => versionObject['version']) |
46 .whenComplete(client.close); | 46 .whenComplete(client.close); |
47 } | 47 } |
48 | 48 |
49 Future<Map> setCurrentRevisions(Map revisions) { | 49 Future setCurrentRevisions(Map revisions) { |
50 return new File('$repository/dart.rb') | 50 return new File('$repository/dart.rb') |
51 .readAsLines() | 51 .readAsLines() |
52 .then((lines) { | 52 .then((lines) { |
53 for (var channel in CHANNELS) { | 53 for (var channel in CHANNELS) { |
54 final regExp = new RegExp('channels/$channel/release/(\\d*)/sdk'); | 54 final regExp = new RegExp('channels/$channel/release/(\\d*)/sdk'); |
55 revisions[channel] = | 55 revisions[channel] = |
56 regExp.firstMatch(lines.firstWhere(regExp.hasMatch)).group(1); | 56 regExp.firstMatch(lines.firstWhere(regExp.hasMatch)).group(1); |
57 } | 57 } |
58 }); | 58 }); |
59 } | 59 } |
60 | 60 |
61 Future<Map> setHashes(Map revisions, Map hashes) { | 61 Future setHashes(Map revisions, Map hashes) { |
62 List waitOn = []; | 62 List waitOn = []; |
63 for (var channel in CHANNELS) { | 63 for (var channel in CHANNELS) { |
64 hashes[channel] = {}; | 64 hashes[channel] = {}; |
65 for (var file in FILES) { | 65 for (var file in FILES) { |
66 waitOn.add(getHash256(channel, revisions[channel], file).then((hash) { | 66 waitOn.add(getHash256(channel, revisions[channel], file).then((hash) { |
67 hashes[channel][file] = hash; | 67 hashes[channel][file] = hash; |
68 })); | 68 })); |
69 } | 69 } |
70 } | 70 } |
71 return Future.wait(waitOn); | 71 return Future.wait(waitOn); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 repository = tempDir.path; | 239 repository = tempDir.path; |
240 }) | 240 }) |
241 .then((_) => runGit( | 241 .then((_) => runGit( |
242 ['clone', 'git@github.com:dart-lang/homebrew-dart.git', '.'])) | 242 ['clone', 'git@github.com:dart-lang/homebrew-dart.git', '.'])) |
243 .then((_) => writeHomebrewInfo(channel, revision)) | 243 .then((_) => writeHomebrewInfo(channel, revision)) |
244 .then((_) => runGit(['commit', '-a', '-m', | 244 .then((_) => runGit(['commit', '-a', '-m', |
245 'Updated $channel branch to revision $revision'])) | 245 'Updated $channel branch to revision $revision'])) |
246 .then((_) => runGit(['push'])) | 246 .then((_) => runGit(['push'])) |
247 .whenComplete(() => new Directory(repository).delete(recursive: true)); | 247 .whenComplete(() => new Directory(repository).delete(recursive: true)); |
248 } | 248 } |
OLD | NEW |