@@ -108,6 +108,7 @@ def __init__(self, url, actor):
108
108
self ._url = url
109
109
self ._actor = actor
110
110
self ._warning_prefix = 'Label Sync Warning:'
111
+ self ._hint_prefix = 'Label Sync Hint:'
111
112
self ._labels = None
112
113
self ._author = None
113
114
self ._draft = None
@@ -262,10 +263,15 @@ def clean_warnings(self):
262
263
created_at = c ['created_at' ]
263
264
if login .startswith ('github-actions' ):
264
265
debug ('github-actions comment %s created at %s on issue %s found' % (comment_id , created_at , issue ))
266
+ prefix = None
265
267
if body .startswith (self ._warning_prefix ):
268
+ prefix = self ._warning_prefix
269
+ if body .startswith (self ._hint_prefix ):
270
+ prefix = self ._hint_prefix
271
+ if prefix :
266
272
created = datetime .strptime (created_at , datetime_format )
267
273
lifetime = today - created
268
- debug ('github-actions %s %s is %s old' % (self . _warning_prefix , comment_id , lifetime ))
274
+ debug ('github-actions %s %s is %s old' % (prefix , comment_id , lifetime ))
269
275
if lifetime > warning_lifetime :
270
276
try :
271
277
self .rest_api ('%s/%s' % (path_args , comment_id ), method = 'DELETE' )
@@ -494,8 +500,15 @@ def actor_valid(self):
494
500
return False
495
501
496
502
coms = self .get_commits ()
497
- authors = sum (com ['authors' ] for com in coms )
498
- authors = [auth for auth in authors if not auth ['login' ] in (self ._actor , 'github-actions' )]
503
+ authors = []
504
+ for com in coms :
505
+ for author in com ['authors' ]:
506
+ login = author ['login' ]
507
+ if not login in authors :
508
+ if not login in (self ._actor , 'github-actions' ):
509
+ debug ('PR %s has recent commit by %s' % (self ._issue , login ))
510
+ authors .append (login )
511
+
499
512
if not authors :
500
513
info ('PR %s can\' t be approved by the author %s since no other person commited to it' % (self ._issue , self ._actor ))
501
514
return False
@@ -571,6 +584,12 @@ def add_warning(self, text):
571
584
"""
572
585
self .add_comment ('%s %s' % (self ._warning_prefix , text ))
573
586
587
+ def add_hint (self , text ):
588
+ r"""
589
+ Perform a system call to ``gh`` to add a hint to an issue or PR.
590
+ """
591
+ self .add_comment ('%s %s' % (self ._hint_prefix , text ))
592
+
574
593
def add_label (self , label ):
575
594
r"""
576
595
Add the given label to the issue or PR.
@@ -624,11 +643,10 @@ def reject_label_removal(self, item):
624
643
a corresponding other one.
625
644
"""
626
645
if type (item ) == State :
627
- sel_list = 'state '
646
+ sel_list = 'status '
628
647
else :
629
648
sel_list = 'priority'
630
- self .add_warning ('Label *%s* can not be removed. Please add the %s-label which should replace it' % (item .value , sel_list ))
631
- self .add_label (item .value )
649
+ self .add_hint ('You don\' t need to remove %s labels any more. You\' d better just add the label which replaces it' % sel_list )
632
650
return
633
651
634
652
# -------------------------------------------------------------------------
@@ -715,6 +733,10 @@ def on_label_removal(self, label):
715
733
return
716
734
717
735
item = sel_list (label )
736
+
737
+ if len (self .active_partners (item )) > 0 :
738
+ return
739
+
718
740
if sel_list is State :
719
741
if self .is_pull_request ():
720
742
if item != State .needs_info :
0 commit comments