##// END OF EJS Templates
pr: Catch errors if target or source reference are missing during commit update. #3950
Martin Bornhold -
r1075:ab74df44 default
parent child Browse files
Show More
@@ -526,7 +526,14 b' class PullRequestModel(BaseModel):'
526 526 old=pull_request, new=None, changes=None)
527 527
528 528 source_repo = pull_request.source_repo.scm_instance()
529 source_commit = source_repo.get_commit(commit_id=source_ref_name)
529 try:
530 source_commit = source_repo.get_commit(commit_id=source_ref_name)
531 except CommitDoesNotExistError:
532 return UpdateResponse(
533 success=False,
534 reason=UpdateFailureReason.MISSING_SOURCE_REF,
535 old=pull_request, new=None, changes=None)
536
530 537 if source_ref_id == source_commit.raw_id:
531 538 log.debug("Nothing changed in pull request %s", pull_request)
532 539 return UpdateResponse(
@@ -543,10 +550,16 b' class PullRequestModel(BaseModel):'
543 550 target_ref_id = pull_request.target_ref_parts.commit_id
544 551 target_repo = pull_request.target_repo.scm_instance()
545 552
546 if target_ref_type in ('tag', 'branch', 'book'):
547 target_commit = target_repo.get_commit(target_ref_name)
548 else:
549 target_commit = target_repo.get_commit(target_ref_id)
553 try:
554 if target_ref_type in ('tag', 'branch', 'book'):
555 target_commit = target_repo.get_commit(target_ref_name)
556 else:
557 target_commit = target_repo.get_commit(target_ref_id)
558 except CommitDoesNotExistError:
559 return UpdateResponse(
560 success=False,
561 reason=UpdateFailureReason.MISSING_TARGET_REF,
562 old=pull_request, new=None, changes=None)
550 563
551 564 # re-compute commit ids
552 565 old_commit_ids = set(pull_request.revisions)
General Comments 0
You need to be logged in to leave comments. Login now