Commit 3282631
committed
fix(github): recover fork PR re-runs when GitHub omits PR metadata
When someone clicks Re-run on a Pipelines as Code check for a pull
request coming from a fork, GitHub can leave out the usual pull request
details in the webhook payload. That left PAC with no obvious way to
tell which pull request the check belonged to, so the re-run stopped
with an error instead of starting again.
This change teaches PAC to keep looking in a more practical way. If the
first GitHub API says it cannot find the pull request for the commit,
PAC now lists open pull requests in the repository and matches the one
whose head commit SHA is the same. In simple terms: when GitHub does not
hand us the answer directly, we now look through the open pull requests
and find the one built from that exact commit.
The change also checks pull request data attached directly to the
check_run event before falling back to SHA-based lookup, and the tests
now cover both the new fork pull request path and the empty-result error
cases.
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>1 parent 92a3273 commit 3282631
2 files changed
Lines changed: 143 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
317 | 347 | | |
318 | 348 | | |
319 | 349 | | |
320 | 350 | | |
321 | 351 | | |
322 | 352 | | |
323 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
324 | 364 | | |
325 | 365 | | |
326 | 366 | | |
| |||
503 | 543 | | |
504 | 544 | | |
505 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
506 | 552 | | |
507 | 553 | | |
508 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
647 | 740 | | |
648 | 741 | | |
649 | 742 | | |
| |||
678 | 771 | | |
679 | 772 | | |
680 | 773 | | |
| 774 | + | |
681 | 775 | | |
682 | 776 | | |
683 | 777 | | |
| |||
694 | 788 | | |
695 | 789 | | |
696 | 790 | | |
| 791 | + | |
697 | 792 | | |
698 | 793 | | |
699 | 794 | | |
| |||
717 | 812 | | |
718 | 813 | | |
719 | 814 | | |
| 815 | + | |
720 | 816 | | |
721 | 817 | | |
722 | 818 | | |
| |||
0 commit comments