@@ -15,16 +15,24 @@ import 'package:glob/glob.dart';
1515
1616void main (List <String > args) async {
1717 final parser = ArgParser ();
18- parser.addMultiOption ('builder' ,
19- abbr: 'b' ,
20- help: 'Select the builders matching the glob [option is repeatable]' ,
21- splitCommas: false );
22- parser.addOption ('branch' ,
23- abbr: 'B' ,
24- help: 'Select the builders building this branch' ,
25- defaultsTo: 'main' );
26- parser.addOption ('count' ,
27- abbr: 'c' , help: 'List this many commits' , defaultsTo: '1' );
18+ parser.addMultiOption (
19+ 'builder' ,
20+ abbr: 'b' ,
21+ help: 'Select the builders matching the glob [option is repeatable]' ,
22+ splitCommas: false ,
23+ );
24+ parser.addOption (
25+ 'branch' ,
26+ abbr: 'B' ,
27+ help: 'Select the builders building this branch' ,
28+ defaultsTo: 'main' ,
29+ );
30+ parser.addOption (
31+ 'count' ,
32+ abbr: 'c' ,
33+ help: 'List this many commits' ,
34+ defaultsTo: '1' ,
35+ );
2836 parser.addFlag ('help' , help: 'Show the program usage.' , negatable: false );
2937
3038 final options = parser.parse (args);
@@ -41,21 +49,24 @@ ${parser.usage}''');
4149
4250 int count = int .parse (options['count' ]);
4351 final globs = List <Glob >.from (
44- options['builder' ].map ((String pattern) => Glob (pattern)));
52+ options['builder' ].map ((String pattern) => Glob (pattern)),
53+ );
4554
4655 // Download the most recent builds from buildbucket.
4756 const maxBuilds = 1000 ;
48- final url = Uri .parse ('https://cr-buildbucket.appspot.com'
49- '/prpc/buildbucket.v2.Builds/SearchBuilds' );
57+ final url = Uri .parse (
58+ 'https://cr-buildbucket.appspot.com'
59+ '/prpc/buildbucket.v2.Builds/SearchBuilds' ,
60+ );
5061 const maxRetries = 3 ;
5162 const timeout = Duration (seconds: 30 );
5263 final query = jsonEncode ({
5364 'predicate' : {
5465 'builder' : {'project' : 'dart' , 'bucket' : 'ci.sandbox' },
55- 'status' : 'ENDED_MASK'
66+ 'status' : 'ENDED_MASK' ,
5667 },
5768 'pageSize' : maxBuilds,
58- 'fields' : 'builds.*.builder.builder,builds.*.input'
69+ 'fields' : 'builds.*.builder.builder,builds.*.input' ,
5970 });
6071 late Map <String , dynamic > searchResult;
6172 for (int i = 1 ; i <= maxRetries; i++ ) {
@@ -67,16 +78,21 @@ ${parser.usage}''');
6778 ..write (query);
6879 final response = await request.close ().timeout (timeout);
6980 if (response.statusCode != 200 ) {
70- print ('Failed to search for builds: '
71- '${response .statusCode }:${response .reasonPhrase }' );
81+ print (
82+ 'Failed to search for builds: '
83+ '${response .statusCode }:${response .reasonPhrase }' ,
84+ );
7285 exit (1 );
7386 }
7487 const prefix = ")]}'" ;
7588 searchResult = await (response
7689 .cast <List <int >>()
7790 .transform (Utf8Decoder ())
78- .map ((event) =>
79- event.startsWith (prefix) ? event.substring (prefix.length) : event)
91+ .map (
92+ (event) => event.startsWith (prefix)
93+ ? event.substring (prefix.length)
94+ : event,
95+ )
8096 .transform (JsonDecoder ())
8197 .cast <Map <String , dynamic >>()
8298 .first
@@ -86,7 +102,8 @@ ${parser.usage}''');
86102 } on TimeoutException catch (e) {
87103 final inSeconds = e.duration? .inSeconds;
88104 stderr.writeln (
89- 'Attempt $i of $maxRetries timed out after $inSeconds seconds' );
105+ 'Attempt $i of $maxRetries timed out after $inSeconds seconds' ,
106+ );
90107 if (i == maxRetries) {
91108 stderr.writeln ('error: Failed to download $url ' );
92109 exit (1 );
@@ -131,8 +148,10 @@ ${parser.usage}''');
131148 continue ;
132149 }
133150 final commit = input['id' ] as String ;
134- final buildersForCommit =
135- buildersForCommits.putIfAbsent (commit, () => < String > {});
151+ final buildersForCommit = buildersForCommits.putIfAbsent (
152+ commit,
153+ () => < String > {},
154+ );
136155 buildersForCommit.add (builder);
137156 }
138157
@@ -148,9 +167,10 @@ ${parser.usage}''');
148167 }
149168
150169 // List commits run on the most builders.
151- for (final commit in buildersForCommits.keys
152- .where ((commit) => buildersForCommits[commit]! .length == maxBots)
153- .take (count)) {
170+ for (final commit
171+ in buildersForCommits.keys
172+ .where ((commit) => buildersForCommits[commit]! .length == maxBots)
173+ .take (count)) {
154174 print (commit);
155175 }
156176}
0 commit comments