@@ -336,37 +336,32 @@ async fn add_team_owner(
336
336
krate : & Crate ,
337
337
login : & str ,
338
338
) -> Result < NewOwnerInvite , OwnerAddError > {
339
- // Always recreate teams to get the most up-to-date GitHub ID
339
+ // github:rust-lang:owners
340
340
let mut chunks = login. split ( ':' ) ;
341
- let team = match chunks. next ( ) . unwrap ( ) {
342
- // github:rust-lang:owners
343
- "github" => {
344
- // unwrap is documented above as part of the calling contract
345
- let org = chunks. next ( ) . unwrap ( ) ;
346
- let team = chunks. next ( ) . ok_or_else ( || {
347
- bad_request (
348
- "missing github team argument; \
349
- format is github:org:team",
350
- )
351
- } ) ?;
352
- Team :: create_or_update_github_team (
353
- gh_client,
354
- conn,
355
- & login. to_lowercase ( ) ,
356
- org,
357
- team,
358
- req_user,
359
- )
360
- . await ?
361
- }
362
- _ => {
363
- return Err ( bad_request (
364
- "unknown organization handler, \
365
- only 'github:org:team' is supported",
366
- )
367
- . into ( ) ) ;
368
- }
369
- } ;
341
+
342
+ let team_system = chunks. next ( ) . unwrap ( ) ;
343
+ if team_system != "github" {
344
+ let error = "unknown organization handler, only 'github:org:team' is supported" ;
345
+ return Err ( bad_request ( error) . into ( ) ) ;
346
+ }
347
+
348
+ // unwrap is documented above as part of the calling contract
349
+ let org = chunks. next ( ) . unwrap ( ) ;
350
+ let team = chunks. next ( ) . ok_or_else ( || {
351
+ let error = "missing github team argument; format is github:org:team" ;
352
+ bad_request ( error)
353
+ } ) ?;
354
+
355
+ // Always recreate teams to get the most up-to-date GitHub ID
356
+ let team = Team :: create_or_update_github_team (
357
+ gh_client,
358
+ conn,
359
+ & login. to_lowercase ( ) ,
360
+ org,
361
+ team,
362
+ req_user,
363
+ )
364
+ . await ?;
370
365
371
366
// Teams are added as owners immediately, since the above call ensures
372
367
// the user is a team member.
0 commit comments