@@ -4,7 +4,7 @@ use log::{debug, error, info, warn};
4
4
use octocrab:: params:: teams:: Permission ;
5
5
use octocrab:: OctocrabBuilder ;
6
6
use serde:: { Deserialize , Serialize } ;
7
- use std:: { collections:: HashMap , hash :: Hash } ;
7
+ use std:: collections:: HashMap ;
8
8
9
9
/// A struct that represents the ghctl configuration for a GitHub repository
10
10
#[ derive( Debug , Serialize , Deserialize ) ]
@@ -169,8 +169,7 @@ impl RepoConfig {
169
169
pub async fn validate_and_prefetch (
170
170
& self ,
171
171
access_token : & str ,
172
- owner : & str ,
173
- repo_name : & str ,
172
+ owner : & str
174
173
) -> Result < ( HashMap < String , u64 > , HashMap < String , HashMap < String , u64 > > ) > {
175
174
let mut users = HashMap :: new ( ) ;
176
175
@@ -192,7 +191,7 @@ impl RepoConfig {
192
191
if let Some ( teams) = self . teams . as_ref ( ) {
193
192
let org = orgs_teams
194
193
. entry ( owner. to_string ( ) )
195
- . or_insert_with ( || HashMap :: new ( ) ) ;
194
+ . or_insert_with ( HashMap :: new) ;
196
195
197
196
for team_slug in teams. keys ( ) {
198
197
debug ! ( "Validating team {team_slug}" ) ;
@@ -203,7 +202,7 @@ impl RepoConfig {
203
202
}
204
203
205
204
if let Some ( environments) = self . environments . as_ref ( ) {
206
- for ( _environment_name , repo_environment) in environments {
205
+ for repo_environment in environments. values ( ) {
207
206
if let Some ( reviewers) = & repo_environment. reviewers {
208
207
for reviewer in reviewers {
209
208
match reviewer. split_once ( '/' ) {
@@ -213,7 +212,7 @@ impl RepoConfig {
213
212
} else {
214
213
let teams = orgs_teams
215
214
. entry ( org. to_string ( ) )
216
- . or_insert_with ( || HashMap :: new ( ) ) ;
215
+ . or_insert_with ( HashMap :: new) ;
217
216
if !teams. contains_key ( team_slug) {
218
217
debug ! ( "Validating team {team_slug}" ) ;
219
218
let team = octocrab. teams ( org) . get ( team_slug) . await ?;
@@ -244,7 +243,7 @@ impl RepoConfig {
244
243
repo_name : & String ,
245
244
) -> anyhow:: Result < ( ) > {
246
245
let ( users, orgs_teams) = self
247
- . validate_and_prefetch ( access_token, owner, repo_name )
246
+ . validate_and_prefetch ( access_token, owner)
248
247
. await ?;
249
248
debug ! ( "Applying configuration" ) ;
250
249
let octocrab = OctocrabBuilder :: default ( )
@@ -516,7 +515,7 @@ mod tests {
516
515
println ! ( "repo_config: {:?}" , repo_config) ;
517
516
518
517
let ( users, teams) = repo_config
519
- . validate_and_prefetch ( & github_token, "gitsudo-io" , "gitsudo" )
518
+ . validate_and_prefetch ( & github_token, "gitsudo-io" )
520
519
. await ?;
521
520
assert ! ( !users. is_empty( ) ) ;
522
521
assert ! ( * users. get( "aisrael" ) . unwrap( ) == 89215 ) ;
0 commit comments