Skip to content

fix(bin): read cross-repo PR checks from the head repository - #5796

Closed
mehulbhagwani wants to merge 1 commit into
kunchenguid:mainfrom
mehulbhagwani:fm/fm-contributions-cross-repo-checks
Closed

mehulbhagwani wants to merge 1 commit into
kunchenguid:mainfrom
mehulbhagwani:fm/fm-contributions-cross-repo-checks

Conversation

@mehulbhagwani

Copy link
Copy Markdown

Problem

fm-contributions.sh queried check-runs and commit statuses against the
PR's base repository, even when the PR's head commit only exists on a
fork. GitHub's commits API silently returns zero results for a SHA it
cannot resolve in that repository, so a contribution whose PR page is
on the base repo but whose commits live on a fork (e.g. a PR opened
mehulbhagwani:branch -> kunchenguid/firstmate:main) was observed as
having no checks at all instead of its real check-run results.

Reproduced directly against #4932:
querying repos/kunchenguid/firstmate/commits/<sha>/check-runs returns
total_count: 0, while repos/mehulbhagwani/firstmate/commits/<sha>/check-runs
returns the real 20 check-runs for that commit.

Fix

Read .head.repo.full_name from the PR core response and query
check-runs and statuses there instead of the base repo, falling back to
the base repository when the head repo field is absent (a deleted
fork).

Testing

  • Reproduced against the real PR via a scratch FM_HOME before and
    after the fix, confirming checks went from empty to the real 20
    check-runs with no error.
  • Added test_cross_repo_checks_use_head_repo to
    tests/fm-contributions.test.sh, asserting check-runs/statuses are
    read from the head repo and not the base repo when they differ.
  • tests/fm-contributions.test.sh passes (40/40).

fm-contributions.sh queried check-runs and commit statuses against the
PR's base repository, even when the head commit only exists on a fork.
GitHub's commits API silently returns zero results for a SHA it cannot
resolve in that repository, so a cross-repo PR was observed as having
no checks at all.

Read .head.repo.full_name from the PR core response and query check-runs
and statuses there instead, falling back to the base repository when the
head repo is absent (a deleted fork).
@mehulbhagwani

Copy link
Copy Markdown
Author

Superseded by #5919; will close once it lands.

@mehulbhagwani

Copy link
Copy Markdown
Author

Closing as superseded by #5919, which carries the same fix rebased on current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant