@@ -2641,11 +2641,24 @@ def update_pull_request(
26412641 fn = "cla.models.github_models.update_pull_request"
26422642 notification = cla .conf ["GITHUB_PR_NOTIFICATION" ]
26432643 both = notification == "status+comment" or notification == "comment+status"
2644- last_commit_sha = getattr (getattr (pull_request , "head" , None ), "sha" , None )
2644+ cla .log .debug (f"{ fn } - Updating PR { pull_request .number } with notification={ notification } , both={ both } " )
2645+ try :
2646+ last_commit_sha = getattr (getattr (pull_request , "head" , None ), "sha" , None )
2647+ repo = getattr (getattr (pull_request , "head" , None ), "repo" , None )
2648+ if repo is None :
2649+ repo = getattr (getattr (pull_request , "base" , None ), "repo" , None )
2650+ commit_obj = repo .get_commit (last_commit_sha )
2651+ except (GithubException , AttributeError , TypeError ) as exc :
2652+ cla .log .error (f"{ fn } - PR { pull_request .number } : exception getting head.sha: { exc } " )
2653+ try :
2654+ commit_obj = pull_request .get_commits ().reversed [0 ]
2655+ last_commit_sha = commit_obj .sha
2656+ except Exception as exc2 :
2657+ cla .log .error (f"{ fn } - PR { pull_request .number } : exception getting last commit from PR commits: { exc2 } " )
2658+ last_commit_sha = None
26452659 if not last_commit_sha :
26462660 cla .log .error (f"{ fn } - PR { pull_request .number } : missing head.sha; cannot create statuses" )
26472661 return
2648- commit_obj = pull_request .base .repo .get_commit (last_commit_sha )
26492662
26502663 # Here we update the PR status by adding/updating the PR body - this is the way the EasyCLA app
26512664 # knows if it is pass/fail.
@@ -2814,7 +2827,7 @@ def create_commit_status(commit_obj, state, sign_url, body, context):
28142827 resp = commit_obj .create_status (state , sign_url , body , context )
28152828 cla .log .info (
28162829 f"Successfully posted status '{ state } ': Commit { sha } "
2817- f"with SignUrl : { sign_url } with response: { resp } "
2830+ f"with SignUrl: { sign_url } with response: { resp } "
28182831 )
28192832 except GithubException as exc :
28202833 sha = getattr (commit_obj , "sha" , "(unknown)" )
0 commit comments