@@ -58,7 +58,7 @@ pub(super) async fn command_approve(
5858
5959 let approver = match approver {
6060 Approver :: Myself => author. username . clone ( ) ,
61- Approver :: Specified ( approver) => approver . clone ( ) ,
61+ Approver :: Specified ( approver) => normalize_approvers ( approver ) ,
6262 } ;
6363 let approval_info = ApprovalInfo {
6464 approver : approver. clone ( ) ,
@@ -74,6 +74,16 @@ pub(super) async fn command_approve(
7474 handle_label_trigger ( & repo_state, pr. github , LabelTrigger :: Approved ) . await
7575}
7676
77+ /// Normalize approvers (given after @bors r=) by removing leading @, possibly from multiple
78+ /// usernames split by a comma.
79+ fn normalize_approvers ( approvers : & str ) -> String {
80+ approvers
81+ . split ( ',' )
82+ . map ( |approver| approver. trim_start_matches ( '@' ) )
83+ . collect :: < Vec < & str > > ( )
84+ . join ( "," )
85+ }
86+
7787/// Keywords that will prevent an approval if they appear in the PR's title.
7888/// They are checked in a case-insensitive manner.
7989const WIP_KEYWORDS : & [ & str ] = & [ "wip" , "[do not merge]" ] ;
@@ -514,6 +524,44 @@ approved = ["+approved"]
514524 . await ;
515525 }
516526
527+ #[ sqlx:: test]
528+ async fn approve_normalize_approver ( pool : sqlx:: PgPool ) {
529+ run_test ( pool, async |ctx : & mut BorsTester | {
530+ ctx. post_comment ( "@bors r=@foo" ) . await ?;
531+ insta:: assert_snapshot!(
532+ ctx. get_next_comment_text( ( ) ) . await ?,
533+ @"
534+ :pushpin: Commit pr-1-sha has been approved by `foo`
535+
536+ It is now in the [queue](https://bors-test.com/queue/borstest) for this repository.
537+ "
538+ ) ;
539+
540+ ctx. pr ( ( ) ) . await . expect_approved_by ( "foo" ) ;
541+ Ok ( ( ) )
542+ } )
543+ . await ;
544+ }
545+
546+ #[ sqlx:: test]
547+ async fn approve_normalize_approver_multiple ( pool : sqlx:: PgPool ) {
548+ run_test ( pool, async |ctx : & mut BorsTester | {
549+ ctx. post_comment ( "@bors r=@foo,bar,@baz" ) . await ?;
550+ insta:: assert_snapshot!(
551+ ctx. get_next_comment_text( ( ) ) . await ?,
552+ @"
553+ :pushpin: Commit pr-1-sha has been approved by `foo,bar,baz`
554+
555+ It is now in the [queue](https://bors-test.com/queue/borstest) for this repository.
556+ "
557+ ) ;
558+
559+ ctx. pr ( ( ) ) . await . expect_approved_by ( "foo,bar,baz" ) ;
560+ Ok ( ( ) )
561+ } )
562+ . await ;
563+ }
564+
517565 #[ sqlx:: test]
518566 async fn insufficient_permission_approve ( pool : sqlx:: PgPool ) {
519567 run_test ( pool, async |ctx : & mut BorsTester | {
0 commit comments