3
3
import toml
4
4
import json
5
5
import re
6
+ import functools
6
7
from . import utils
7
8
from .utils import lazy_debug
8
9
import logging
@@ -448,22 +449,24 @@ def parse_commands(body, username, repo_cfg, state, my_username, db, states,
448
449
global global_cfg
449
450
state_changed = False
450
451
451
- _reviewer_auth_verified = verify_auth (
452
+ _reviewer_auth_verified = functools .partial (
453
+ verify_auth ,
452
454
username ,
453
455
repo_cfg ,
454
456
state ,
455
457
AuthState .REVIEWER ,
456
458
realtime ,
457
- my_username
459
+ my_username ,
458
460
)
459
461
460
- _try_auth_verified = verify_auth (
462
+ _try_auth_verified = functools .partial (
463
+ verify_auth ,
461
464
username ,
462
465
repo_cfg ,
463
466
state ,
464
467
AuthState .TRY ,
465
468
realtime ,
466
- my_username
469
+ my_username ,
467
470
)
468
471
469
472
words = get_words (body , my_username )
@@ -475,7 +478,7 @@ def parse_commands(body, username, repo_cfg, state, my_username, db, states,
475
478
for i , word in reversed (list (enumerate (words ))):
476
479
found = True
477
480
if word == 'r+' or word .startswith ('r=' ):
478
- if not _reviewer_auth_verified :
481
+ if not _reviewer_auth_verified () :
479
482
continue
480
483
481
484
if not sha and i + 1 < len (words ):
@@ -489,29 +492,29 @@ def parse_commands(body, username, repo_cfg, state, my_username, db, states,
489
492
continue
490
493
491
494
elif word == 'r-' :
492
- if not _reviewer_auth_verified :
495
+ if not _reviewer_auth_verified () :
493
496
continue
494
497
review_rejected (state , realtime )
495
498
496
499
elif word .startswith ('p=' ):
497
- if not _try_auth_verified :
500
+ if not _try_auth_verified () :
498
501
continue
499
- if not set_priority (state , word [len ('p=' ):], global_cfg ):
502
+ if not set_priority (state , realtime , word [len ('p=' ):], global_cfg ):
500
503
continue
501
504
502
505
elif word .startswith ('delegate=' ):
503
- if not _reviewer_auth_verified :
506
+ if not _reviewer_auth_verified () :
504
507
continue
505
508
delegate_to (state , realtime , word [len ('delegate=' ):])
506
509
507
510
elif word == 'delegate-' :
508
511
# TODO: why is this a TRY?
509
- if not _try_auth_verified :
512
+ if not _try_auth_verified () :
510
513
continue
511
514
delegate_negative (state )
512
515
513
516
elif word == 'delegate+' :
514
- if not _reviewer_auth_verified :
517
+ if not _reviewer_auth_verified () :
515
518
continue
516
519
delegate_positive (state ,
517
520
state .get_repo ().
@@ -525,35 +528,35 @@ def parse_commands(body, username, repo_cfg, state, my_username, db, states,
525
528
retry (state )
526
529
527
530
elif word in ['try' , 'try-' ] and realtime :
528
- if not _try_auth_verified :
531
+ if not _try_auth_verified () :
529
532
continue
530
- _try (state , word , realtime )
533
+ _try (state , word )
531
534
532
535
elif word in ['rollup' , 'rollup-' ]:
533
- if not _try_auth_verified :
536
+ if not _try_auth_verified () :
534
537
continue
535
538
rollup (state , word )
536
539
537
540
elif word == 'force' and realtime :
538
- if not _try_auth_verified :
541
+ if not _try_auth_verified () :
539
542
continue
540
543
force (repo_cfg , state )
541
544
542
545
elif word == 'clean' and realtime :
543
- if not _try_auth_verified :
546
+ if not _try_auth_verified () :
544
547
continue
545
548
clean (state )
546
549
547
550
elif (word == 'hello?' or word == 'ping' ) and realtime :
548
551
hello_or_ping (state )
549
552
550
553
elif word .startswith ('treeclosed=' ):
551
- if not _reviewer_auth_verified :
554
+ if not _reviewer_auth_verified () :
552
555
continue
553
556
set_treeclosed (state , word )
554
557
555
558
elif word == 'treeclosed-' :
556
- if not _reviewer_auth_verified :
559
+ if not _reviewer_auth_verified () :
557
560
continue
558
561
treeclosed_negative (state )
559
562
0 commit comments