File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -595,13 +595,27 @@ def set_status(
595595 head_sha : str ,
596596 build_url : str ,
597597) -> bool :
598- status : dict [str , str ] = {
598+ new_status : dict [str , str ] = {
599599 "state" : "success" ,
600600 "description" : STATUS_SUCCESS_DESCRIPTION ,
601601 "context" : STATUS_CONTEXT ,
602602 "target_url" : build_url ,
603603 }
604- response = api .session .post (f"{ API } /repos/{ repo } /statuses/{ head_sha } " , json = status )
604+
605+ for status in api .paginate (
606+ f"{ API } /repos/{ repo } /commits/{ head_sha } /status" ,
607+ item_key = "statuses" ,
608+ ):
609+ if status ["context" ] == STATUS_CONTEXT :
610+ if all (status [k ] == new_status [k ] for k in new_status ):
611+ return True
612+ # Otherwise, needs update
613+ break
614+ # If no existing status with the same context exists, we need to create one.
615+
616+ response = api .session .post (
617+ f"{ API } /repos/{ repo } /statuses/{ head_sha } " , json = new_status
618+ )
605619 if response .status_code == 403 :
606620 logging .warning (
607621 "No permission to set commit status; "
You can’t perform that action at this time.
0 commit comments