@@ -425,11 +425,16 @@ fn calculate_permission_diffs(
425
425
permissions. push ( diff) ;
426
426
}
427
427
// Bot permissions
428
- let bots = expected_repo. bots . iter ( ) . filter_map ( |b| {
429
- let bot_user_name = bot_user_name ( b) ?;
430
- actual_teams. remove ( bot_user_name) ;
431
- Some ( ( bot_user_name, RepoPermission :: Write ) )
432
- } ) ;
428
+ let bots = expected_repo
429
+ . bots
430
+ . iter ( )
431
+ . filter_map ( |b| match BotDetails :: from ( b) {
432
+ BotDetails :: User { name, permission } => {
433
+ actual_teams. remove ( name) ;
434
+ Some ( ( name, permission) )
435
+ }
436
+ BotDetails :: GitHubApp => None ,
437
+ } ) ;
433
438
// Member permissions
434
439
let members = expected_repo
435
440
. members
@@ -482,20 +487,34 @@ fn calculate_permission_diffs(
482
487
Ok ( permissions)
483
488
}
484
489
485
- /// Returns `None` if the bot is not an actual bot user, but rather a GitHub app.
486
- fn bot_user_name ( bot : & Bot ) -> Option < & str > {
487
- match bot {
488
- // FIXME: set this to `None` once homu is removed completely
489
- Bot :: Bors => Some ( "bors" ) ,
490
- Bot :: Highfive => Some ( "rust-highfive" ) ,
491
- Bot :: RustTimer => Some ( "rust-timer" ) ,
492
- Bot :: Rustbot => Some ( "rustbot" ) ,
493
- Bot :: Rfcbot => Some ( "rfcbot" ) ,
494
- Bot :: Craterbot => Some ( "craterbot" ) ,
495
- Bot :: Glacierbot => Some ( "rust-lang-glacier-bot" ) ,
496
- Bot :: LogAnalyzer => Some ( "rust-log-analyzer" ) ,
497
- Bot :: Renovate => None ,
498
- Bot :: HerokuDeployAccess => Some ( "rust-heroku-deploy-access" ) ,
490
+ enum BotDetails {
491
+ User {
492
+ name : & ' static str ,
493
+ permission : RepoPermission ,
494
+ } ,
495
+ GitHubApp ,
496
+ }
497
+
498
+ impl From < & Bot > for BotDetails {
499
+ fn from ( bot : & Bot ) -> Self {
500
+ let user = |name, permission| BotDetails :: User { name, permission } ;
501
+ let write_access = |name| user ( name, RepoPermission :: Write ) ;
502
+ let admin_access = |name| user ( name, RepoPermission :: Admin ) ;
503
+
504
+ match bot {
505
+ Bot :: Bors => write_access ( "bors" ) ,
506
+ Bot :: Highfive => write_access ( "rust-highfive" ) ,
507
+ Bot :: Rustbot => write_access ( "rustbot" ) ,
508
+ Bot :: RustTimer => write_access ( "rust-timer" ) ,
509
+ Bot :: Rfcbot => write_access ( "rfcbot" ) ,
510
+ Bot :: Craterbot => write_access ( "craterbot" ) ,
511
+ Bot :: Glacierbot => write_access ( "rust-lang-glacier-bot" ) ,
512
+ Bot :: LogAnalyzer => write_access ( "rust-log-analyzer" ) ,
513
+ Bot :: Renovate => BotDetails :: GitHubApp ,
514
+ // Unfortunately linking to Heroku requires admin access, since the integration creates
515
+ // GitHub webhooks, which require admin access.
516
+ Bot :: HerokuDeployAccess => admin_access ( "rust-heroku-deploy-access" ) ,
517
+ }
499
518
}
500
519
}
501
520
0 commit comments