Files
react-native/.github/actions/diff-js-api-changes
Alex Hunt 88a6ace533 Fix JS API change false positives for out-of-sync branches (#56871)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56871

`diff-js-api-changes` was posting false positive "JavaScript API change detected" warnings on PRs that never modified `ReactNativeApi.d.ts`.

This happened because the action ran `git merge-base` against limited local history (`git fetch --depth=500`), which couldn't find the common ancestor for branches that were far behind main — including (often) pick requests to release branches. The fallback wrote an empty "before" snapshot, causing the entire API surface to appear newly added.

{F1989977284}

#### Changes

- Query the GitHub API first — if the PR doesn't touch `ReactNativeApi.d.ts`, skip the diff entirely.
- When the snapshot is touched, use the GitHub compare API to resolve the merge base instead of relying on local git history.
- Limit the check to PRs targeting `main` or `*-stable` branches.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D105572432

fbshipit-source-id: 20e5db01c9e6b51acb55548746c8fd512a363274
2026-05-20 12:01:36 -07:00
..