@@ -408,7 +408,17 @@ def get_commits(self):
408
408
return self ._commits
409
409
410
410
self ._commits = self .view ('commits' )
411
- self ._commit_date = max ( com ['committedDate' ] for com in self ._commits )
411
+
412
+ # ignore merge commits with the develop branch for _commit_date unless positive review is set
413
+ date_commits = list (self ._commits )
414
+ if Status .positive_review .value not in self .get_labels ():
415
+ for com in self ._commits :
416
+ message = com ['messageHeadline' ]
417
+ if message .startswith ('Merge' ) and 'develop' in message :
418
+ debug ('Ignore merge commit %s for commit_date' % com ['oid' ])
419
+ date_commits .remove (com )
420
+
421
+ self ._commit_date = max (com ['committedDate' ] for com in date_commits )
412
422
info ('Commits until %s for %s: %s' % (self ._commit_date , self ._issue , self ._commits ))
413
423
return self ._commits
414
424
@@ -1034,6 +1044,35 @@ def run_tests(self):
1034
1044
elif self .is_pull_request ():
1035
1045
self .run (action )
1036
1046
1047
+ def test_method (self , method , * args , ** kwds ):
1048
+ r"""
1049
+ Run the given method for testing.
1050
+
1051
+ EXAMPLES::
1052
+
1053
+ sage$ python .github/sync_labels.py https://github.com/sagemath/sage/pull/40634 soehms is_auth_team_member "{'login': 'soehms'}" -t
1054
+ INFO:root:cmdline_args (4) ['https://github.com/sagemath/sage/pull/40634', 'soehms', 'is_auth_team_member', "{'login': 'soehms'}"]
1055
+ ...
1056
+ DEBUG:root:call is_auth_team_member with args () and kwds {'login': 'soehms'}
1057
+ DEBUG:root:================================================================================
1058
+ DEBUG:root:Execute command: gh api -X GET -H "Accept: application/vnd.github+json" /orgs/sagemath/teams/triage/memberships/soehms
1059
+ INFO:root:User soehms is a member of triage
1060
+ INFO:root:result of is_auth_team_member with args () and kwds {'login': 'soehms'} is True
1061
+ INFO:root:================================================================================
1062
+ ...
1063
+ """
1064
+ if hasattr (self , method ):
1065
+ meth = self .__getattribute__ (method )
1066
+ if callable (meth ):
1067
+ debug ('call %s with args %s and kwds %s' % (method , args , kwds ))
1068
+ debug ('=' * 80 )
1069
+ res = meth (* args , ** kwds )
1070
+ info ('result of %s with args %s and kwds %s is %s' % (method , args , kwds , res ))
1071
+ info ('=' * 80 )
1072
+ debug ('state of self: %s' % self .__dict__ )
1073
+ return
1074
+ raise ValueError ('%s is not a method of %s' % (method , self ))
1075
+
1037
1076
1038
1077
###############################################################################
1039
1078
# Main
@@ -1068,8 +1107,10 @@ def run_tests(self):
1068
1107
num_args = len (cmdline_args )
1069
1108
info ('cmdline_args (%s) %s' % (num_args , cmdline_args ))
1070
1109
1071
- if run_tests and num_args in (1 ,2 ):
1072
- if num_args == 2 :
1110
+ if run_tests :
1111
+ if num_args == 4 :
1112
+ url , actor , method , args = cmdline_args
1113
+ elif num_args == 2 :
1073
1114
url , actor = cmdline_args
1074
1115
else :
1075
1116
url , = cmdline_args
@@ -1079,7 +1120,10 @@ def run_tests(self):
1079
1120
info ('actor: %s' % actor )
1080
1121
1081
1122
gh = GhLabelSynchronizer (url , actor )
1082
- gh .run_tests ()
1123
+ if num_args == 4 :
1124
+ gh .test_method (method , ** eval (args ))
1125
+ else :
1126
+ gh .run_tests ()
1083
1127
1084
1128
elif num_args == 5 :
1085
1129
action , url , actor , label , rev_state = cmdline_args
0 commit comments