@@ -14,7 +14,9 @@ pub struct RepoArch {
14
14
}
15
15
16
16
#[ derive( Deserialize , Serialize , Debug , Clone ) ]
17
- pub struct CommitBuildInfo {
17
+ pub struct EnabledRepo {
18
+ #[ serde( flatten) ]
19
+ pub repo_arch : RepoArch ,
18
20
pub prev_endtime_for_commit : Option < u64 > ,
19
21
}
20
22
@@ -237,26 +239,19 @@ impl BuildMeta {
237
239
Ok ( ( ) )
238
240
}
239
241
240
- pub fn get_commit_build_info ( & self , srcmd5 : & str ) -> HashMap < RepoArch , CommitBuildInfo > {
241
- let mut repos = HashMap :: new ( ) ;
242
-
243
- for ( repo, jobhist) in & self . repos {
244
- let prev_endtime_for_commit = jobhist
245
- . jobhist
246
- . iter ( )
247
- . filter ( |e| e. srcmd5 == srcmd5)
248
- . next_back ( )
249
- . map ( |e| e. endtime ) ;
250
-
251
- repos. insert (
252
- repo. clone ( ) ,
253
- CommitBuildInfo {
254
- prev_endtime_for_commit,
255
- } ,
256
- ) ;
257
- }
258
-
259
- repos
242
+ pub fn get_commit_build_info ( & self , srcmd5 : & str ) -> Vec < EnabledRepo > {
243
+ self . repos
244
+ . iter ( )
245
+ . map ( |( repo, jobhist) | EnabledRepo {
246
+ repo_arch : repo. clone ( ) ,
247
+ prev_endtime_for_commit : jobhist
248
+ . jobhist
249
+ . iter ( )
250
+ . filter ( |e| e. srcmd5 == srcmd5)
251
+ . next_back ( )
252
+ . map ( |e| e. endtime ) ,
253
+ } )
254
+ . collect ( )
260
255
}
261
256
}
262
257
@@ -360,10 +355,10 @@ mod tests {
360
355
361
356
let build_info = meta. get_commit_build_info ( & srcmd5_1) ;
362
357
363
- let arch_1 = assert_some ! ( build_info. get ( & repo_arch_1) ) ;
358
+ let arch_1 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_1) ) ;
364
359
assert_some_eq ! ( arch_1. prev_endtime_for_commit, endtime_1) ;
365
360
366
- let arch_2 = assert_some ! ( build_info. get ( & repo_arch_2) ) ;
361
+ let arch_2 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_2) ) ;
367
362
assert_none ! ( arch_2. prev_endtime_for_commit) ;
368
363
369
364
let meta = assert_ok ! (
@@ -385,9 +380,9 @@ mod tests {
385
380
386
381
let build_info = meta. get_commit_build_info ( & srcmd5_1) ;
387
382
388
- let arch_1 = assert_some ! ( build_info. get ( & repo_arch_1) ) ;
383
+ let arch_1 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_1) ) ;
389
384
assert_none ! ( arch_1. prev_endtime_for_commit) ;
390
- let arch_2 = assert_some ! ( build_info. get ( & repo_arch_2) ) ;
385
+ let arch_2 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_2) ) ;
391
386
assert_none ! ( arch_2. prev_endtime_for_commit) ;
392
387
393
388
assert ! ( meta. repos. contains_key( & repo_arch_2) ) ;
@@ -431,7 +426,7 @@ mod tests {
431
426
432
427
let build_info = meta. get_commit_build_info ( & srcmd5_2) ;
433
428
434
- let arch_1 = assert_some ! ( build_info. get ( & repo_arch_2) ) ;
429
+ let arch_1 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_2) ) ;
435
430
assert_some_eq ! ( arch_1. prev_endtime_for_commit, endtime_2) ;
436
431
437
432
mock. add_job_history (
@@ -465,13 +460,13 @@ mod tests {
465
460
466
461
let build_info = meta. get_commit_build_info ( & srcmd5_1) ;
467
462
468
- let arch_2 = assert_some ! ( build_info. get ( & repo_arch_2) ) ;
463
+ let arch_2 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_2) ) ;
469
464
assert_some_eq ! ( arch_2. prev_endtime_for_commit, endtime_1) ;
470
465
471
466
meta. clear_stored_history ( ) ;
472
467
473
468
let build_info = meta. get_commit_build_info ( & srcmd5_1) ;
474
- let arch_2 = assert_some ! ( build_info. get ( & repo_arch_2) ) ;
469
+ let arch_2 = assert_some ! ( build_info. iter ( ) . find ( |e| e . repo_arch == repo_arch_2) ) ;
475
470
assert_none ! ( arch_2. prev_endtime_for_commit) ;
476
471
477
472
mock. set_package_build_status (
0 commit comments